You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Stephan Windmüller (Jira)" <ji...@apache.org> on 2024/01/30 13:53:00 UTC

[jira] [Created] (HTTPCLIENT-2316) ConnectionShutdownException when connection is closed for 401 response

Stephan Windmüller created HTTPCLIENT-2316:
----------------------------------------------

             Summary: ConnectionShutdownException when connection is closed for 401 response
                 Key: HTTPCLIENT-2316
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2316
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (classic)
    Affects Versions: 5.3.1
         Environment: Ubuntu Linux, Java 17.0.10, connecting to an Apache Web Server
            Reporter: Stephan Windmüller


When a connection is used for multiple requests, the {{Keep-Alive}} header has a {{max}} value that is reduced until it reaches 0, resulting in a {{Connection: closed}} header. If that happens while a 401 response is handled, the following code is executed:
{code:java}
org.apache.hc.client5.http.impl.classic.InternalExecRuntime.markConnectionNonReusable(InternalExecRuntime.java:233)
	at org.apache.hc.client5.http.impl.classic.MainClientExec.execute(MainClientExec.java:142)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:188)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:113)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:87)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:55)
	at org.apache.hc.client5.http.classic.HttpClient.executeOpen(HttpClient.java:183)
	at org.apache.hc.client5.http.fluent.Request.internalExecute(Request.java:201)
	at org.apache.hc.client5.http.fluent.Executor.execute(Executor.java:244)
{code}
After that, {{org.apache.hc.client5.http.impl.classic.InternalExecRuntime#disconnectEndpoint}} is called. Any further attempt to use that connection results in this stacktrace:
{code:java}
org.apache.hc.client5.http.impl.ConnectionShutdownException
	at org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager$InternalConnectionEndpoint.getConnection(BasicHttpClientConnectionManager.java:502)
	at org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager$InternalConnectionEndpoint.isConnected(BasicHttpClientConnectionManager.java:519)
	at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.isEndpointConnected(InternalExecRuntime.java:149)
	at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:128)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:113)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:87)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:55)
	at org.apache.hc.client5.http.classic.HttpClient.executeOpen(HttpClient.java:183)
	at org.apache.hc.client5.http.fluent.Request.internalExecute(Request.java:201)
	at org.apache.hc.client5.http.fluent.Executor.execute(Executor.java:244)
{code}
The behaviour sounds a bit like HTTPASYNC-63.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org