[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17869439#comment-17869439
 ] 

Alex commented on HTTPCLIENT-2334:
----------------------------------

I don't do that, available() returns Integer.MAX_VALUE all the time since I 
don't know how much data will be coming through.

If returning zero when no data is available is required the documentation 
should make it a lot more clear. Now it says that it's a "hint".

Generally it's not very clear why "produce" needs to be called multiple 
times... one can stash the 
DataStreamChannel on first call and use it as needed later or 
immediately.DataStreamChannel has methods to signal the "end of stream" and 
"request output".
 
I'll look into modifying my implementation of available.

> AsyncDataProducer.produce gets into a tight loop
> ------------------------------------------------
>
>                 Key: HTTPCLIENT-2334
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2334
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient (async)
>    Affects Versions: 5.2.2
>            Reporter: Alex
>            Priority: Major
>
> I am using async data transfer for http request (POST) and using 
> AsyncDataProducer interface produce method. This method seems to be called 
> multiple times in a tight NIO loop when it does not immediately produce data 
> when called. In my case it needs to store the provided DataStreamChannel and 
> return, so that DataStreamChannel can be used later when data for the request 
> is available. However the method seems to be called again immediately in a 
> tight loop and is causing high CPU consumption. Effectively I had to make it 
> blocking which is not the intent of the API.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to