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 2017/05/09 20:03:06 UTC
[15/50] httpcomponents-core git commit: HTTPCORE-331: fixed possible
race condition in case of an exceptional condition (such as an I/O error)
HTTPCORE-331: fixed possible race condition in case of an exceptional condition (such as an I/O error)
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.2.x@1435160 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/576ac96e
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/576ac96e
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/576ac96e
Branch: refs/heads/4.2.x
Commit: 576ac96e8c891a653d61e9ca55c93cc8e80378c9
Parents: d0569b2
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Jan 18 14:31:52 2013 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Jan 18 14:31:52 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/http/nio/protocol/HttpAsyncRequester.java | 3 ++-
.../java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/576ac96e/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
index 84dee82..12f9d81 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
@@ -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();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/576ac96e/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
index 89e42b7..7006760 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
@@ -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,