Community
Participate
Working Groups
The implementation of ReliableFile assumes that InputStream.available returns the size of the input stream. But this is clearly not the case. I think we need to stop using the available method in this class altogether and simply use a BufferedInputStream to always get the mark support we need regardless of the size of the file. Currently if the size of the file is "too big" the ReliableFile implementation will fail to read the contents correctly.
Created attachment 198670 [details] patch + test After more investigation the issue is that we use the available() method to incorrectly determine the size of the file and in the case where available() returns something bigger than our default maxInputStreamBuffer then we read the whole input stream to find the CRC and then try to continue to use that fully consumed input stream. This patch fixes two issues: 1) it stops using available() to incorrectly determine the size of the file. Instead we use File.length() 2) for files larger than maxInputStreamBuffer we correctly read the complete file to obtain the CRC and then close that fully consumed input stream and then open a new input stream to be consumed by the client of the API. For smaller files < maxInputStreamBuffer we use a BufferedInputStream to correctly mark/reset after obtaining the CRC.
Created attachment 198676 [details] updatec patch Updated patch to make sure we don't try to use mark when the file length is longer than the integer max.
patch release.