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

vyom tewari vyom.tewari at oracle.com
Fri Oct 27 06:01:57 UTC 2017



On Thursday 26 October 2017 03:14 PM, Bernd Eckenfels wrote:
> What is currently returned at the end of a stream? This looks like a 
> dangerous thing to do, if a existing implementation only
Currently it returns 0 at end of stream and  same as after change. As 
David pointed out that ultimately it delegates on to "ioctl", i checked 
the doc(http://man7.org/linux/man-pages/man4/tty_ioctl.4.html) and did 
not found anything which tells about eof.

What i found out, setting eof at socketinputstream there is no effect on 
native  "ioctl" call. I set the "eof"  and SocketInputStream.available() 
return 0.

Let's wait for other people opinions.

Note: you have to shutdown the SocketInputstream to set "eof", i am not 
sure if there is any other way to set "eof" for SocketInputStream.

Thanks,
Vyom

> read when something is available it might never detect that it reached 
> EOF.
>
> Gruss
> Bernd
> -- 
> http://bernd.eckenfels.net
> ------------------------------------------------------------------------
> *From:* net-dev <net-dev-bounces at openjdk.java.net> on behalf of vyom 
> tewari <vyom.tewari at oracle.com>
> *Sent:* Thursday, October 26, 2017 11:26:15 AM
> *To:* OpenJDK Network Dev list
> *Subject:* RFR: 8189366: SocketInputStream.available() should check 
> for eof
> Hi All,
>
> Please review the simple change below.
>
> Webrev   : 
> http://cr.openjdk.java.net/~vtewari/8189366/webrev0.0/index.html 
> <http://cr.openjdk.java.net/%7Evtewari/8189366/webrev0.0/index.html>
>
> BugId      : https://bugs.openjdk.java.net/browse/JDK-8189366
>
>
> Currently SocketInputStream.available() does not check for "eof" and
> simply delegate to the impl even when "eof" reached. I put a check  to
> return 0 if "eof" is already reached.
>
> Thanks,
>
> Vyom
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/net-dev/attachments/20171027/2a06f40e/attachment.html>


More information about the net-dev mailing list