On Thu, 21 Jul 2022 10:47:38 GMT, Prasanta Sadhukhan <[email protected]> wrote:
> 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. This pull request has now been integrated. Changeset: a17fce75 Author: Prasanta Sadhukhan <[email protected]> URL: https://git.openjdk.org/jdk/commit/a17fce7507c7d485d51f98fadd444235ea31058d Stats: 134 lines in 2 files changed: 118 ins; 12 del; 4 mod 6445283: ProgressMonitorInputStream not large file aware (>2GB) Reviewed-by: azvegint, prr ------------- PR: https://git.openjdk.org/jdk/pull/9588
