Noah Levitt created HTTPCLIENT-1287:
---------------------------------------

             Summary: DefaultUserTokenHandler.getUserToken() throws 
ConnectionShutdownException after certain aborted fetches
                 Key: HTTPCLIENT-1287
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1287
             Project: HttpComponents HttpClient
          Issue Type: Bug
    Affects Versions: 4.3 Alpha1
            Reporter: Noah Levitt


DefaultUserTokenHandler.getUserToken() throws ConnectionShutdownException after 
certain aborted fetches, resulting in this:

java.io.InterruptedIOException: Connection has been shut down
        at 
org.apache.http.impl.client.execchain.MainClientExec.execute(MainClientExec.java:322)
        at 
org.apache.http.impl.client.execchain.ProtocolExec.execute(ProtocolExec.java:170)
        at 
org.apache.http.impl.client.execchain.RetryExec.execute(RetryExec.java:77)
        at 
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at 
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:69)
        at 
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:1)
        [...]
Caused by: org.apache.http.impl.conn.ConnectionShutdownException
        at org.apache.http.impl.conn.CPoolProxy.invoke(CPoolProxy.java:121)
        at $Proxy0.getSSLSession(Unknown Source)
        at 
org.apache.http.impl.client.DefaultUserTokenHandler.getUserToken(DefaultUserTokenHandler.java:81)
        at 
org.apache.http.impl.client.execchain.MainClientExec.execute(MainClientExec.java:305)
        ... 33 more

I haven't narrowed down a minimal test case, but I can tell you that this 
change fixes it:

Index: 
httpclient/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
===================================================================
--- 
httpclient/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
        (revision 1427210)
+++ 
httpclient/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
        (working copy)
@@ -76,7 +76,7 @@
 
         if (userPrincipal == null) {
             HttpConnection conn = clientContext.getConnection();
-            if (conn instanceof SocketClientConnection) {
+            if (conn instanceof SocketClientConnection && conn.isOpen()) {
                 SSLSession sslsession = ((SocketClientConnection) 
conn).getSSLSession();
                 if (sslsession != null) {
                     userPrincipal = sslsession.getLocalPrincipal();


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to