You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Sebastiano Vigna <vi...@dsi.unimi.it> on 2010/11/13 22:00:25 UTC

Trouble with eof-of-file sensing

I'm getting literally crazy trying to figure out if and when HttpClient has closed the connection stream automatically.

The behaviour existed in 3.1 (AutoCloseInputStream), and I found indications that HttpClient 4 had solved the problem... well, no. Now it's called EofSensorWatcher, but the problem is the same: you perform a read() and instead of -1 you get an exception.

My question is: how can I know whether the InputStream content of an Entity returned by a response has been closed automatically? I'm getting spurious IOExceptions everywhere. Unfortunately, nobody seems to have the problem--I couldn't find any relevant information by Googling around.

Any help appreciated.

Ciao,

				seba



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Trouble with eof-of-file sensing

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2010-11-13 at 22:00 +0100, Sebastiano Vigna wrote:
> I'm getting literally crazy trying to figure out if and when HttpClient has closed the connection stream automatically.
> 
> The behaviour existed in 3.1 (AutoCloseInputStream), and I found indications that HttpClient 4 had solved the problem... well, no. Now it's called EofSensorWatcher, but the problem is the same: you perform a read() and instead of -1 you get an exception.
> 
> My question is: how can I know whether the InputStream content of an Entity returned by a response has been closed automatically? 

EofSensorInputStream class automatically releases the underlying input
stream as soon as it gets -1 from a read operation. All subsequent read
operations will always return -1. The EofSensorInputStream will not
throw an exception on a read operation as long as it has not been
explicitly closed with #close() method.


> I'm getting spurious IOExceptions everywhere. Unfortunately, nobody seems to have the problem--I couldn't find any relevant information by Googling around.
> 

What kind of spurious IOExceptions are you getting?

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org