RFR: 6445283: ProgressMonitorInputStream not large file aware (>2GB)
Prasanta Sadhukhan
psadhukhan at openjdk.org
Thu Jul 21 10:57:28 UTC 2022
If ProgressMonitor has to show progress for reading file > 2GB, it goes to 100% and then again start from 0.
This is because
it uses "int" to store bytes read (`nread`) and when it reads data from file, it adds
"number-bytes-to-read "nr" to number-bytes-already-read "nread" variable [`nread += nr`] which can cause it to overflow and so "nread" becomes -ve.
Fix is to check if adding bytes-to-read to number-bytes-already-read will exceed MAX_INT, then set Progress to max so that ProgressMonitor can close the tracker
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/ProgressMonitor.java#L265
No regression test is added as it involves using filesize of >2GB.
-------------
Commit messages:
- 6445283: ProgressMonitorInputStream not large file aware (>2GB)
Changes: https://git.openjdk.org/jdk/pull/9588/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9588&range=00
Issue: https://bugs.openjdk.org/browse/JDK-6445283
Stats: 21 lines in 1 file changed: 18 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/9588.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/9588/head:pull/9588
PR: https://git.openjdk.org/jdk/pull/9588
More information about the client-libs-dev
mailing list