RFR 8193842: Refactor InputStream-to-OutputStream copy into a utility method (original) (raw)
Brian Burkhalter brian.burkhalter at oracle.com
Fri Dec 22 21:51:17 UTC 2017
- Previous message: [10] RFR 8075939: Stream.flatMap() causes breaking of short-circuiting of terminal operations
- Next message: RFR 8193842: Refactor InputStream-to-OutputStream copy into a utility method
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
https://bugs.openjdk.java.net/browse/JDK-8194133 http://cr.openjdk.java.net/~bpb/8194133/webrev.00/
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.
Thanks,
Brian
- Previous message: [10] RFR 8075939: Stream.flatMap() causes breaking of short-circuiting of terminal operations
- Next message: RFR 8193842: Refactor InputStream-to-OutputStream copy into a utility method
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]