hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1435160 - in /httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src: main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
Date Fri, 18 Jan 2013 14:31:52 GMT
Author: olegk
Date: Fri Jan 18 14:31:52 2013
New Revision: 1435160

URL: http://svn.apache.org/viewvc?rev=1435160&view=rev
Log:
HTTPCORE-331: fixed possible race condition in case of an exceptional condition (such as an
I/O error)

Modified:
    httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
    httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java

Modified: httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java?rev=1435160&r1=1435159&r2=1435160&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
(original)
+++ httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
Fri Jan 18 14:31:52 2013
@@ -110,7 +110,6 @@ public class HttpAsyncRequester {
     private <T> void doExecute(
             final HttpAsyncRequestExecutionHandler<T> handler, final NHttpClientConnection
conn) {
         conn.getContext().setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, handler);
-        conn.requestOutput();
         if (!conn.isOpen()) {
             handler.failed(new ConnectionClosedException("Connection closed"));
             try {
@@ -118,6 +117,8 @@ public class HttpAsyncRequester {
             } catch (IOException ex) {
                 log(ex);
             }
+        } else {
+            conn.requestOutput();
         }
     }
 

Modified: httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java?rev=1435160&r1=1435159&r2=1435160&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
(original)
+++ httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
Fri Jan 18 14:31:52 2013
@@ -162,6 +162,7 @@ public class TestHttpAsyncRequester {
 
     @Test
     public void testSimpleExecute() throws Exception {
+        Mockito.when(this.conn.isOpen()).thenReturn(Boolean.TRUE);
         Future<Object> future = this.requester.execute(
                 this.requestProducer,
                 this.responseConsumer,



Mime
View raw message