hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1556021 - in /httpcomponents/httpasyncclient/trunk: ./ httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/
Date Mon, 06 Jan 2014 20:36:05 GMT
Author: olegk
Date: Mon Jan  6 20:36:05 2014
New Revision: 1556021

URL: http://svn.apache.org/r1556021
Log:
HTTPASYNC-63: ConnectionShutdownException thrown in case of out-of-sequence response

Modified:
    httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java

Modified: httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt?rev=1556021&r1=1556020&r2=1556021&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt Mon Jan  6 20:36:05 2014
@@ -1,6 +1,9 @@
 Changes since 4.0
 -------------------
 
+* [HTTPASYNC-63] ConnectionShutdownException thrown in case of out-of-sequence response.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-1442] Authentication header set by the user gets removed in case
   of proxy authentication.
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java?rev=1556021&r1=1556020&r2=1556021&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java
Mon Jan  6 20:36:05 2014
@@ -172,9 +172,10 @@ class DefaultClientExchangeHandlerImpl<T
             }
             this.completed.set(true);
         } else {
-            final NHttpClientConnection localConn = this.managedConn.get();
-            if (localConn != null &&!localConn.isOpen()) {
+            NHttpClientConnection localConn = this.managedConn.get();
+            if (localConn != null && !localConn.isOpen()) {
                 releaseConnection();
+                localConn = null;
             }
             if (localConn != null) {
                 localConn.requestOutput();

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java?rev=1556021&r1=1556020&r2=1556021&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java
Mon Jan  6 20:36:05 2014
@@ -364,7 +364,8 @@ class MainClientExec implements Internal
             }
         }
 
-        if (this.connReuseStrategy.keepAlive(currentResponse, localContext)) {
+        final NHttpClientConnection managedConn = connManager.getConnection();
+        if (managedConn.isOpen() && this.connReuseStrategy.keepAlive(currentResponse,
localContext)) {
             final long validDuration = this.keepaliveStrategy.getKeepAliveDuration(
                     currentResponse, localContext);
             if (this.log.isDebugEnabled()) {
@@ -380,7 +381,9 @@ class MainClientExec implements Internal
             state.setReusable();
         } else {
             if (this.log.isDebugEnabled()) {
-                this.log.debug("[exchange: " + state.getId() + "] Connection cannot be kept
alive");
+                if (managedConn.isOpen()) {
+                    this.log.debug("[exchange: " + state.getId() + "] Connection cannot be
kept alive");
+                }
             }
             state.setNonReusable();
             connManager.releaseConnection();

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java?rev=1556021&r1=1556020&r2=1556021&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java
Mon Jan  6 20:36:05 2014
@@ -35,6 +35,7 @@ import java.lang.reflect.Proxy;
 import org.apache.http.HttpConnection;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.impl.conn.ConnectionShutdownException;
+import org.apache.http.nio.IOControl;
 import org.apache.http.nio.NHttpClientConnection;
 import org.apache.http.nio.conn.ManagedNHttpClientConnection;
 import org.apache.http.util.Asserts;
@@ -130,7 +131,12 @@ class CPoolProxy implements InvocationHa
         } else {
             final NHttpClientConnection conn = getConnection();
             if (conn == null) {
-                throw new ConnectionShutdownException();
+                if (method.getDeclaringClass().equals(IOControl.class)) {
+                    // Ignore IOControl operations on closed connections
+                    return null;
+                } else {
+                    throw new ConnectionShutdownException();
+                }
             }
             try {
                 return method.invoke(conn, args);



Mime
View raw message