RFR: 8297632: InputStream.transferTo() method should specify what the return value should be when the number of bytes transfered is larger than Long.MAX_VALUE
Brian Burkhalter
bpb at openjdk.org
Tue Nov 29 18:28:14 UTC 2022
On Tue, 29 Nov 2022 00:56:58 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> `java.io.InputStream::transferTo` could conceivably return a negative value if the count of bytes transferred overflows a `long`. Modify the method to limit the number of bytes transferred to `Long.MAX_VALUE` per invocation.
Modified in 254d6990bcf75700f1c3aa18e0f8b73b639d9bad to transfer all bytes but clamp the return value to `Long.MAX_VALUE`. Overrides in `java.io` were already examined and do not appear problematic but a second check would not hurt.
-------------
PR: https://git.openjdk.org/jdk/pull/11403
More information about the core-libs-dev
mailing list