You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2013/01/18 15:31:52 UTC
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
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,