Found different in behavior of SocketInputStream#read in JDK13

Enrico Olivelli eolivelli at gmail.com
Tue Jul 30 15:45:38 UTC 2019


Hello,
in Apache ZooKeeper community we discovered a difference in behavior in
SocketInputStream.

The problem is that SocketInputStream#read used to throw a SocketException
instead of returning -1.

I see that this was cited in https://openjdk.java.net/jeps/353

"The InputStream and OutputStream returned by the old implementation tests
the stream for EOF and returns -1 before other checks. The new
implementation does null and bounds checks before checking if the stream is
at EOF. It is possible, but unlikely, that there is fragile code that will
trip up due to the order of the checks."

We are talking about a unit test, no a big deal.

This is the fix, provided by Mate Szalay-Beko
https://github.com/apache/zookeeper/pull/1029

I hope that helps

Enrico Olivelli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190730/538c21a5/attachment.html>


More information about the nio-dev mailing list