RFR: 8189366: SocketInputStream.available() should check for eof

Alan Bateman Alan.Bateman at oracle.com
Fri Oct 12 14:35:05 UTC 2018


On 12/10/2018 14:43, David Lloyd wrote:
> On Fri, Oct 12, 2018 at 6:01 AM Chris Hegarty <chris.hegarty at oracle.com> wrote:
>> That is correct. While not intuitive, I don't propose
>> that we change this. ( if this were a new implementation
>> then I think it should throw IOE for this scenario, but
>> we are where we are ).
> I am glad then that it is not a new implementation.  Returning an EOF
> signal is a very reasonable behavior for a closed input stream or
> input channel.
It's an interesting discussion point as it will likely depend on the 
protocol as to how premature EOF is handled. Also if you asynchronously 
close the socket then it will be random as to whether a reader on the 
same socket will read -1 or throw an exception.

-Alan


More information about the net-dev mailing list