Found different in behavior of SocketInputStream#read in JDK13
Enrico Olivelli
eolivelli at gmail.com
Wed Jul 31 08:26:53 UTC 2019
Il giorno mar 30 lug 2019 alle ore 20:53 Alan Bateman <
Alan.Bateman at oracle.com> ha scritto:
> 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.
>
This is the exception on JDK12 and on JDK13 with
-Djdk.net.usePlainSocketImpl
java.net.SocketException: Connection reset
at
java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
at
java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at
org.apache.zookeeper.server.quorum.UnifiedServerSocketTest.testConnectWithoutSSLToStrictServer(UnifiedServerSocketTest.java:408)
Enrico
> -Alan.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190731/58a2bcd6/attachment.html>
More information about the nio-dev
mailing list