Socket InputStream.available may return a positive value after shutdown

Alan Bateman Alan.Bateman at oracle.com
Wed Apr 27 03:35:43 PDT 2011


Jing LV wrote:
> Hello,
>
>     Currently I don't see any patch available so I am trying to create 
> one by myself. I see the problem occurs in 
> AbstractPlainSocketImpl.available() and it seems it is design to 
> return 0 when meed a closed socket - this may not be correct according 
> to the spec, thus change it like this. Would someone review please?
I don't think I understand your proposed change as the connection isn't 
reset in this case. Maybe you meant to change available to check 
shut_rd? In any case, I think we need to be cautious as it would change 
the behavior for the EOF case and so could cause problems for existing 
applications. There is also a concern for custom SocketImpl 
implementations that I mentioned previously. I think that whatever 
approach is decided on will also require adding clarification to the 
javadoc. So if it's okay with you, I think we should postpone this to 8.

-Alan



More information about the net-dev mailing list