Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.1.2, 5.2-alpha2
    • 5.1.3, 5.2-beta1
    • None
    • None
    • OpenJDK 64-Bit Server VM Temurin-11.0.13+8

    Description

      When trying to download a file from https://lei.kdpw.pl/DownloadCFFull.aspx using async client I get an exception:

      java.lang.IllegalStateException: Current state = RESET, new state = FLUSHED
      	at java.base/java.nio.charset.CharsetDecoder.throwIllegalStateException(CharsetDecoder.java:989)
      	at java.base/java.nio.charset.CharsetDecoder.flush(CharsetDecoder.java:672)
      	at org.apache.hc.core5.http2.hpack.HPackDecoder.decodeString(HPackDecoder.java:211)
      	at org.apache.hc.core5.http2.hpack.HPackDecoder.decodeLiteralHeader(HPackDecoder.java:242)
      	at org.apache.hc.core5.http2.hpack.HPackDecoder.decodeHPackHeader(HPackDecoder.java:273)
      	at org.apache.hc.core5.http2.hpack.HPackDecoder.decodeHeaders(HPackDecoder.java:297)
      	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.decodeHeaders(AbstractH2StreamMultiplexer.java:1052)
      	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeHeaderFrame(AbstractH2StreamMultiplexer.java:1067)
      	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeFrame(AbstractH2StreamMultiplexer.java:770)
      	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.onInput(AbstractH2StreamMultiplexer.java:444)
      	at org.apache.hc.core5.http2.impl.nio.AbstractH2IOEventHandler.inputReady(AbstractH2IOEventHandler.java:65)
      	at org.apache.hc.core5.http2.impl.nio.ClientH2IOEventHandler.inputReady(ClientH2IOEventHandler.java:39)
      	at org.apache.hc.client5.http.impl.async.LoggingIOSession$1.inputReady(LoggingIOSession.java:238)
      	at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:549)
      	at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$400(SSLIOSession.java:72)
      	at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:172)
      	at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:131)
      	at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
      	at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178)
      	at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127)
      	at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85)
      	at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      

      This doesn't happen in blocking client, nor when I'll force async client to use HTTP 1.

      Attachments

        1. MainHttp2BugReproducer.java
          6 kB
          Dominik Derwiński

        Activity

          While preparing a reproducer I've noticed this also no longer happens if I remove CharCodingConfig from client parameters:

          .setCharCodingConfig(CharCodingConfig.custom()
                              .setCharset(StandardCharsets.UTF_8)
                              .build())
          

          What's funny is that this is decribed as "HTTP/1.1 char coding configuration." so shouldn't apply to HTTP/2? Also, blocking client had no trouble working with PoolingHttpClientConnectionManager using ManagedHttpClientConnectionFactory using such CharCodingConfig.

          morvael Dominik Derwiński added a comment - While preparing a reproducer I've noticed this also no longer happens if I remove CharCodingConfig from client parameters: .setCharCodingConfig(CharCodingConfig.custom() .setCharset(StandardCharsets.UTF_8) .build()) What's funny is that this is decribed as "HTTP/1.1 char coding configuration." so shouldn't apply to HTTP/2? Also, blocking client had no trouble working with PoolingHttpClientConnectionManager using ManagedHttpClientConnectionFactory using such CharCodingConfig.
          morvael Dominik Derwiński added a comment - - edited

          I have attached reproducer. It will not crash in current form, but will crash once setCharCodingConfig line will be uncommented, and again not crash when setVersionPolicy will be uncommented too (add missing import when doing that).

          morvael Dominik Derwiński added a comment - - edited I have attached reproducer. It will not crash in current form, but will crash once setCharCodingConfig line will be uncommented, and again not crash when setVersionPolicy will be uncommented too (add missing import when doing that).

          Commit 5f1b3600296b4ec7d7c806453d39a1a70082462b in httpcomponents-core's branch refs/heads/HTTPCORE-704 from Oleg Kalnichevski
          [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=5f1b360 ]

          HTTPCORE-704: HPackDecoder fails to correctly decode an empty header if a non-ASCII charset is being used

          jira-bot ASF subversion and git services added a comment - Commit 5f1b3600296b4ec7d7c806453d39a1a70082462b in httpcomponents-core's branch refs/heads/ HTTPCORE-704 from Oleg Kalnichevski [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=5f1b360 ] HTTPCORE-704 : HPackDecoder fails to correctly decode an empty header if a non-ASCII charset is being used

          morvael It looks like the defect is trggered by two conditions: HPack header being empty and non-ASCII charset being used. Please review / test the fix:

          https://github.com/apache/httpcomponents-core/commit/5f1b3600296b4ec7d7c806453d39a1a70082462b

          Oleg

          olegk Oleg Kalnichevski added a comment - morvael It looks like the defect is trggered by two conditions: HPack header being empty and non-ASCII charset being used. Please review / test the fix: https://github.com/apache/httpcomponents-core/commit/5f1b3600296b4ec7d7c806453d39a1a70082462b Oleg

          Oleg,

          Looks ok, indeed the problem was caused by calling flush on a "clean/empty" decoder, so early exit will help here.

          morvael Dominik Derwiński added a comment - Oleg, Looks ok, indeed the problem was caused by calling flush on a "clean/empty" decoder, so early exit will help here.

          Commit b6c573c86d041d591cf0ae7b1f39d025cb9e185b in httpcomponents-core's branch refs/heads/5.1.x from Oleg Kalnichevski
          [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=b6c573c ]

          HTTPCORE-704: HPackDecoder fails to correctly encode / decode an empty header if a non-ASCII charset is being used

          jira-bot ASF subversion and git services added a comment - Commit b6c573c86d041d591cf0ae7b1f39d025cb9e185b in httpcomponents-core's branch refs/heads/5.1.x from Oleg Kalnichevski [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=b6c573c ] HTTPCORE-704 : HPackDecoder fails to correctly encode / decode an empty header if a non-ASCII charset is being used

          Commit b313afc611c16936e8c69c6bc533864014b70f4d in httpcomponents-core's branch refs/heads/master from Oleg Kalnichevski
          [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=b313afc ]

          HTTPCORE-704: HPackDecoder fails to correctly encode / decode an empty header if a non-ASCII charset is being used

          jira-bot ASF subversion and git services added a comment - Commit b313afc611c16936e8c69c6bc533864014b70f4d in httpcomponents-core's branch refs/heads/master from Oleg Kalnichevski [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=b313afc ] HTTPCORE-704 : HPackDecoder fails to correctly encode / decode an empty header if a non-ASCII charset is being used

          Fixed in 5.1.x and master.

          Oleg

          olegk Oleg Kalnichevski added a comment - Fixed in 5.1.x and master. Oleg

          Commit b6c573c86d041d591cf0ae7b1f39d025cb9e185b in httpcomponents-core's branch refs/heads/github_ci_on_win from Oleg Kalnichevski
          [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=b6c573c86 ]

          HTTPCORE-704: HPackDecoder fails to correctly encode / decode an empty header if a non-ASCII charset is being used

          jira-bot ASF subversion and git services added a comment - Commit b6c573c86d041d591cf0ae7b1f39d025cb9e185b in httpcomponents-core's branch refs/heads/github_ci_on_win from Oleg Kalnichevski [ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=b6c573c86 ] HTTPCORE-704 : HPackDecoder fails to correctly encode / decode an empty header if a non-ASCII charset is being used

          People

            Unassigned Unassigned
            morvael Dominik Derwiński
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: