Found different in behavior of SocketInputStream#read in JDK13
Alan Bateman
Alan.Bateman at oracle.com
Tue Jul 30 18:53:34 UTC 2019
On 30/07/2019 08:45, Enrico Olivelli wrote:
> 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
>
Thanks for the mail. What is the exception you see with the legacy
implementation? The note you cite would lead to an
IndexOutOfBoundException due to the bad input and I don't think this is
what you are seeing.
-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190730/2108564b/attachment.html>
More information about the nio-dev
mailing list