On Sat, 2014-01-04 at 21:46 -0800, Alex Oscherov wrote:
> Oleg,
> thank you for getting in touch.
> I validated that version that I use is 4.0 GA.
>
> Stuff that I've mentioned is the test that we use to check how
> http-async-client works with our code. Unfortunately test is manual so we
> don't run it too often. I am sure that this test worked after you provided
> the fix for HTTPASYNC-51. We picked the fix from from the source tree build
> and our test ran without problem it was beta4 with your fix. Now with 4.0
> GA it fails.
> Please let me know what more details we can provide. Reproducible case
> would require you to have Exchange server installed so I am not sure how
> realistic is that.
>
> Thank you,
> Alex Oscherov
>
Hi Alex
It is a bug in HttpAsyncClient. The problem is not so much the length of
the request body but the fact that the server responds out of sequence
with 401 status.
Please raise a JIRA for this issue. Please also try out the patch
attached and let me know if fixes the problem.
Cheers
Oleg
diff --git a/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java b/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java
index 499a082..5fa5923 100644
--- a/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java
+++ b/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultClientExchangeHandlerImpl.java
@@ -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();
diff --git a/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java b/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java
index 2de07c6..0438bd3 100644
--- a/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java
+++ b/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java
@@ -364,7 +364,8 @@ class MainClientExec implements InternalClientExec {
}
}
- 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 InternalClientExec {
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();
diff --git a/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java b/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java
index adaf654..978b2f4 100644
--- a/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java
+++ b/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/CPoolProxy.java
@@ -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 InvocationHandler {
} 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);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]