You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Laurian Vostinar (Jira)" <ji...@apache.org> on 2023/01/12 13:09:00 UTC

[jira] [Created] (HTTPCLIENT-2257) BasicAsyncEntityProducer error on second time send

Laurian Vostinar created HTTPCLIENT-2257:
--------------------------------------------

             Summary: BasicAsyncEntityProducer error on second time send 
                 Key: HTTPCLIENT-2257
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2257
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (async)
    Affects Versions: 5.1.4
            Reporter: Laurian Vostinar


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 ?



--
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