RFR: 8272297: FileInputStream should override transferTo() for better performance

Alan Bateman alanb at openjdk.java.net
Thu Aug 12 11:33:26 UTC 2021


On Thu, 12 Aug 2021 01:16:04 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Please consider this request to add an override `java.io.FileInputStream.transferTo(OutputStream)` with improved performance if the parameter is a `FileOutputStream`.

Changes requested by alanb (Reviewer).

src/java.base/share/classes/java/io/FileInputStream.java line 371:

> 369:                 // not, then use the superclass method to copy those remaining
> 370:                 if (fci.transferTo(pos, count, fco) == count) {
> 371:                     return count;

Are you sure this is right? FileChannel transferTo doesn't modify the source channel's position so I assume the method above will finish with the InputStream at its initial position rather than EOF. How are we on test coverage for this case?

-------------

PR: https://git.openjdk.java.net/jdk/pull/5097


More information about the core-libs-dev mailing list