RFR 8193842: Refactor InputStream-to-OutputStream copy into a utility method
brian.burkhalter at oracle.com
Fri Dec 22 21:51:17 UTC 2017
Add jdk.internal.io.IOSupport with copy() methods for InputStream-to-OutputStream copying and modify some classes to use these new methods.
One thing that I noticed when looking at this is that in the fix for https://bugs.openjdk.java.net/browse/JDK-8193842, the Files.copy() method had a loop like
while ((n = read(…)) > 0)
whereas InputStream.transferTo() had
while((n = read(…)) >= 0)
which is to say that Files.copy() would terminate if there were an empty read() but transferTo() would not. The patch for 8193842 therefore possibly introduced a subtle behavioral change which no one noticed.
More information about the core-libs-dev