hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r825864 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
Date Fri, 16 Oct 2009 12:22:27 GMT
Author: olegk
Date: Fri Oct 16 12:22:27 2009
New Revision: 825864

URL: http://svn.apache.org/viewvc?rev=825864&view=rev
Log:
HTTPCLIENT-881: Fixed race condition in AbstractClientConnAdapter that makes it possible for
an aborted connection to be returned to the pool
Contributed by Tim Boemker <tboemker at elynx.com>

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=825864&r1=825863&r2=825864&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Fri Oct 16 12:22:27 2009
@@ -1,6 +1,11 @@
 Changes since 4.0
 -------------------
 
+* [HTTPCLIENT-881] Fixed race condition in AbstractClientConnAdapter that makes it
+  possible for an aborted connection to be returned to the pool.
+  Contributed by Tim Boemker <tboemker at elynx.com> and 
+  Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-832] Distinguish cookie format errors from violations of restrictions 
   imposed by a cookie specification. In the latter case 
   CookieRestrictionViolationException will be thrown.

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java?rev=825864&r1=825863&r2=825864&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
Fri Oct 16 12:22:27 2009
@@ -83,8 +83,8 @@
     /** The reusability marker. */
     private volatile boolean markedReusable;
 
-    /** True if the connection has been aborted. */
-    private volatile boolean aborted;
+    /** True if the connection has been shut down or released. */
+    private volatile boolean shutdown;
     
     /** The duration this is valid for while idle (in ms). */
     private volatile long duration;
@@ -104,7 +104,7 @@
         connManager = mgr;
         wrappedConnection = conn;
         markedReusable = false;
-        aborted = false;
+        shutdown = false;
         duration = Long.MAX_VALUE;
     } // <constructor>
 
@@ -133,7 +133,7 @@
      * @throws InterruptedIOException   if the connection has been aborted
      */
     protected final void assertNotAborted() throws InterruptedIOException {
-        if (aborted) {
+        if (shutdown) {
             throw new InterruptedIOException("Connection has been shut down.");
         }
     }
@@ -160,7 +160,7 @@
     }
 
     public boolean isStale() {
-        if (aborted)
+        if (shutdown)
             return true;
         OperatedClientConnection conn = getWrappedConnection();
         if (conn == null)
@@ -316,16 +316,17 @@
     }
 
     public void releaseConnection() {
+        shutdown = true;
         if (connManager != null) {
             connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS);
         }
     }
 
     public void abortConnection() {
-        if (aborted) {
+        if (shutdown) {
             return;
         }
-        aborted = true;
+        shutdown = true;
         unmarkReusable();
         try {
             shutdown();
@@ -345,7 +346,9 @@
         // manager if #abortConnection() is called from the main execution 
         // thread while there is no blocking I/O operation.
         if (executionThread.equals(Thread.currentThread())) {
-            releaseConnection();
+            if (connManager != null) {
+                connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS);
+            }
         }
     }
 



Mime
View raw message