RFR: 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy [v11]
Sean Mullan
mullan at openjdk.java.net
Thu Feb 18 19:24:43 UTC 2021
On Mon, 15 Feb 2021 19:47:00 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
>> 8080272 Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy
>
> Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision:
>
> 8080272: Refactor I/O stream copying to use java.io.InputStream.transferTo
> remove unnecessary file.exists() check
src/java.base/share/classes/sun/security/provider/certpath/X509CertPath.java line 228:
> 226: try {
> 227: if (is.markSupported() == false) {
> 228: // Copy the entire input stream into an InputStream that does
I don't think you should remove lines 228-232. These methods are called by methods of CertificateFactory that take InputStream (which may contain a stream of security data) and they are designed such that they try to read one Certificate, CRL, or CertPath from the InputStream and leave the InputStream ready to parse the next structure instead of consuming all of the bytes. Thus they check if the InputStream supports mark in order to try to preserve that behavior. If mark is not supported, then it's ok to use InputStream.readAllBytes, otherwise, leave the stream as-is.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1853
More information about the nio-dev
mailing list