jira-importer opened a new issue, #1169: URL: https://github.com/apache/httpcomponents-core/issues/1169
**[Malay Shah](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mns)** opened **[HTTPCORE-638](https://issues.apache.org/jira/browse/HTTPCORE-638?redirect=false)** and commented Using `SharedOutputBuffer` in conjunction with `ContentOutputStream` can cause `endStream` to be called multiple times on the `DataStreamChannel`. I've noticed this happening in my code where I'm using something nearly identical `AbstractClassicEntityProducer` (only difference is that I use my own thread to produce the data). When this happens, the `HttpAsyncMainClientExec`'s `messageCountDown` goes to zero and the exchange is considered completed but since no response was processed, it results in a `cancel` callback. I should note that this does not happen all the time but frequently enough when I'm calling into a local web server. Here's how `endStream` ends up being called twice: * Once from the producer thread when it calls close on the `ContentOutputStream` * one from the call to `SharedOutputBuffer.flush` from `OutputStreamClassicEntityProducer.produce`. From my understanding, this sequence is legitimate as `OutputStreamClassicEntityProducer.produce` is called repeatedly, and it can hold on to the DataStreamChannel to call into asynchronously (from the comment in `AsyncDataProducer`). When I've seen this happen, both calls to `endStream` happen within one or two milliseconds of each other. There is no guard in SharedOutputBuffer to ensure that `endStream` is called only once. Is this the correct fix? I'm happy to submit a PR if this the right solution. Thank you! --- **Affects:** 5.0 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
