Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-733

BasicAsyncEntityProducer error on second time send

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.2.1
    • None
    • HttpCore
    • None

    Description

      I use BasicAsyncEntityProducer  to send a small String, UTF-8 encoded. Server respondes with 307 status code so request is sent again. Second time sending fails because bytebuf is broken. Initially bytebuff has limit 24 and capacity 26 (see line  this.bytebuf = charset.encode(CharBuffer.wrap(content)); with UTF-8 encoding); after releaseResources is called  bytebuf has limit and capacity 26 (obviously  this.length is unchanged, still 24). So send will fail because of this:

      ERROR com.servoy.j2db.util.Debug - Error executing a request to /create/chat with method POST with user: null, workstation: null, domain: null java.lang.IllegalStateException: Encoding process already completed
          at org.apache.hc.core5.util.Asserts.check(Asserts.java:38) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.AbstractContentEncoder.assertNotCompleted(AbstractContentEncoder.java:104) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.LengthDelimitedEncoder.write(LengthDelimitedEncoder.java:101) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.streamOutput(AbstractHttp1StreamDuplexer.java:497) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer$1.write(ClientHttp1StreamDuplexer.java:152) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler$1.write(ClientHttp1StreamHandler.java:100) ~[?:?]
          at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1$1.write(HttpAsyncMainClientExec.java:158) ~[?:?]
          at org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer.produce(BasicAsyncEntityProducer.java:132) ~[?:?]
          at org.apache.hc.core5.http.nio.support.BasicRequestProducer.produce(BasicRequestProducer.java:104) ~[?:?]
          at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$2.produce(InternalAbstractHttpAsyncClient.java:278) ~[?:?]
          at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.produce(HttpAsyncMainClientExec.java:149) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.produceOutput(ClientHttp1StreamHandler.java:199) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.produceOutput(ClientHttp1StreamDuplexer.java:338) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onOutput(AbstractHttp1StreamDuplexer.java:368) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.outputReady(AbstractHttp1IOEventHandler.java:73) ~[?:?]
          at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.outputReady(ClientHttp1IOEventHandler.java:39) ~[?:?]
          at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:141) ~[?:?]
          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.lang.Thread.run(Unknown Source) ~[?:?] 

      maybe you should use flip instead of clear ?

      Attachments

        Activity

          People

            Unassigned Unassigned
            laurian Laurian Vostinar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: