Behavior change in sun.misc.IOUtils::readFully introduced in JDK-8236984

David Alvarez alvdavi at amazon.com
Tue Jan 28 10:49:27 UTC 2020


Hi,

JDK-8236984 [1] reintroduced sun.misc.IOUtils::readFully as a wrapper of
readExactlyNBytes/readNBytes [2]. However, there are differences on how
the new wrapper handles -1 as the length [3] compared to how it is
handled originally in 8u232 [4].

It seems this is happening because the wrapper is based on the
implementation of the function present in JDK-8183591 [5]. This patch
was included to ensure a cleaner backport for JDK-8231139 [6]. I do not
know how common people calling IOUtils will be, but I've seen some
usages already and a few StackOverflow comments listing it (explicitly
with the -1 value for length) as solutions for converting InputStreams
to byte[] [7][8].

David

--
[1] https://bugs.openjdk.java.net/browse/JDK-8236984
[2] https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/a42cf24f8be7
[3]
https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/a42cf24f8be7/src/share/classes/sun/misc/IOUtils.java#l304
[4]
https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/5456f24496f4/src/share/classes/sun/misc/IOUtils.java#l53
[5] https://bugs.openjdk.java.net/browse/JDK-8183591
[6] https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/3a28916a398c
[7] https://stackoverflow.com/q/16156970
[8] https://stackoverflow.com/a/36111438


More information about the jdk8u-dev mailing list