On Fri, 22 Jul 2022 09:11:25 GMT, Prasanta Sadhukhan <[email protected]> wrote:
> Yes, the tracker closes when it reaches MAX INT limit 2147483647 since the > progress tracking method setProgress() accepts "int". We can keep the > progress meter at end ie 100% without closing even after reading 2147483647 > bytes, till it reaches EOF or we could add new setProgress() method with long > as you suggested. I had thought about it but was not sure about the > practicality of this scenario, so just thought of addressing by closing the > tracker. Also, InputStream.available() returns an "int" so I guessed filesize > > MAX_INT is not supported which is another reason I did not go for "long" https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/InputStream.html#available() >Returns an estimate of the number of bytes that can be read (or skipped over) >from this input stream without blocking, which may be 0, or 0 when end of >stream is detected. So `InputStream.available()` is not intended to get a real input stream data length. Maybe we should work with `InputStream.available()` not only in constructor, but in `ProgressMonitorInputStream.read()` methods too, since `available()` value can change during the data read. For example, we have `FileInputStream` with a 4GB file: - at the beginning we have MAX INT `available()` - after 1GB read we still have MAX INT available but - after 3GB read we have 1GB available - after 4GB read we have 0 available And we can somehow update progress bar based on this data. ------------- PR: https://git.openjdk.org/jdk/pull/9588
