mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8297632: InputStream.transferTo() method should specify what the return value should be when the number of bytes transfered is larger than Long.MAX_VALUE
Reviewed-by: alanb, lancea
This commit is contained in:
parent
f7dee77d73
commit
5b2d430131
7 changed files with 52 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -392,7 +392,11 @@ public class FileInputStream extends InputStream
|
|||
return transferred;
|
||||
}
|
||||
}
|
||||
return transferred + super.transferTo(out);
|
||||
try {
|
||||
return Math.addExact(transferred, super.transferTo(out));
|
||||
} catch (ArithmeticException ignore) {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
private long length() throws IOException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue