| Summary: | Connections are returned multiple times to the pool in HttpClient | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Michal Dobisek <dobisekm> |
| Component: | WebDAV | Assignee: | Platform-WebDAV-Inbox <platform-webdav-inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | ondrej.chylik |
| Version: | 3.0 | Keywords: | helpwanted |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 2000 | ||
| Whiteboard: | |||
This component is no longer being actively developed. We encourage users to investigate the capabilities of the Eclipse Web Tools Project. |
The PersistentInputStream does not contain any check for multiple closes. If such a case occurs, then the connection is returned to the pool on each close. This could cause strange errors in multi-threaded environment is more threads access the same connection at the same time. This patch fixes the bug: Index: org/eclipse/webdav/http/client/HttpClient.java =================================================================== RCS file: /home/eclipse/org.eclipse.webdav/src/client/org/eclipse/webdav/http/client /HttpClient.java,v retrieving revision 1.10 diff -u -r1.10 HttpClient.java --- org/eclipse/webdav/http/client/HttpClient.java 17 Apr 2004 21:12:07 - 0000 1.10 +++ org/eclipse/webdav/http/client/HttpClient.java 3 Nov 2004 16:38:35 - 0000 @@ -242,7 +242,7 @@ connection = new HttpConnection (originServerUrl); } else { connection = (HttpConnection) unusedConnections.lastElement(); - unusedConnections.removeElementAt (unusedConnections.size() - 1); + unusedConnections.removeElementAt(unusedConnections.size() - 1); } Vector usedConnections = (Vector) this.usedConnections.get(originServerUrl); @@ -285,6 +285,10 @@ this.unusedConnections.put(originServerUrl, unusedConnections); } + if(unusedConnections.contains(connection)) { + System.err.println("Attempt to pool connection twice!, connection ="+connection); + return; + } unusedConnections.addElement(connection); connection.setTimestamp(new Date()); } @@ -361,6 +365,7 @@ * This input stream's connection. */ private HttpConnection connection; + private boolean closed = false; /** * Creates a new persistent input stream on the given connection. @@ -395,14 +400,17 @@ * @see InputStream#close() */ public void close() throws IOException { - try { - super.close(); - } catch (IOException e) { - closeConnection(); - throw e; - } finally { - connectionsRecycler.putConnection(connection); - } + if(!closed) { + closed = true; + try { + super.close(); + } catch (IOException e) { + closeConnection(); + throw e; + } finally { + connectionsRecycler.putConnection(connection); + } + } } private void closeConnection() {