Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2316

ConnectionShutdownException when connection is closed for 401 response

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.3.1
    • 5.4-alpha2
    • HttpClient (classic)
    • None
    • Ubuntu Linux, Java 17.0.10, connecting to an Apache Web Server

    Description

      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:

      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)
      

      After that, org.apache.hc.client5.http.impl.classic.InternalExecRuntime#disconnectEndpoint is called. Any further attempt to use that connection results in this stacktrace:

      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)
      

      The behaviour sounds a bit like HTTPASYNC-63.

      Attachments

        1. log-output-8266a9c.txt
          6 kB
          Stephan Windmüller
        2. log-output-38d8d9b.txt
          6 kB
          Stephan Windmüller
        3. log-output.txt
          20 kB
          Stephan Windmüller

        Issue Links

          Activity

            People

              Unassigned Unassigned
              windy Stephan Windmüller
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: