hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1435161 - in /httpcomponents/httpcore/trunk/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:36:24 GMT
Author: olegk
Date: Fri Jan 18 14:36:24 2013
New Revision: 1435161

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

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

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java?rev=1435161&r1=1435160&r2=1435161&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
Fri Jan 18 14:36:24 2013
@@ -135,7 +135,6 @@ public class HttpAsyncRequester {
     private <T> void initExection(
             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 {
@@ -143,6 +142,8 @@ public class HttpAsyncRequester {
             } catch (final IOException ex) {
                 log(ex);
             }
+        } else {
+            conn.requestOutput();
         }
     }
 

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



Mime
View raw message