On Fri, 10 Feb 2023 17:38:51 GMT, Brian Burkhalter <b...@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. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > > 8297632: Align SequenceInputStream style with other changes in patch src/java.base/share/classes/java/io/SequenceInputStream.java line 249: > 247: transferred = Math.addExact(transferred, > in.transferTo(out)); > 248: } catch (ArithmeticException ignore) { > 249: return Long.MAX_VALUE; @bplb , this looks like a bug to me: once `transferred` reaches `Long.MAX_VALUE` the transfer loop will terminate and the transfer will stop even in the case there are more streams available in the sequence. I think the proper code should be `transferred = Long.MAX_VALUE` instead of `return Long.MAX_VALUE`. What do you think? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/11403#discussion_r1426217875