You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Master SharedFileInputStream closes unexpectedly after GC even if some slave SharedFileInputStream(constructed by newStream()) are still being referenced.
Detailed exception is IOException: Stream Closed
To Reproduce
Steps to reproduce the behavior:
Here's a simple failing test case to reproduce the error.
@Testvoidtest() throwsException {
// you can use any file to testFilefile = Paths.get("src/test/resources/test_file.jpeg").toFile();
InputStreamslaveSharedFileIs = newSharedFileInputStream(file).newStream(0, -1);
System.gc();
Assertions.assertDoesNotThrow(() -> slaveSharedFileIs.read());
}
I guess master SharedFileInputStream which is not referenced anymore calls finalize() and close() when GC works, so slave SharedFileInputStream also cannot access the file after that.
To prove, the test case below succeeds.
@Testvoidtest() throwsException {
// you can use any file to testFilefile = Paths.get("src/test/resources/test_file.jpeg").toFile();
SharedFileInputStreammasterSharedFileIs = newSharedFileInputStream(file);
InputStreamslaveSharedFileIs = masterSharedFileIs.newStream(0, -1);
System.gc();
Assertions.assertDoesNotThrow(() -> slaveSharedFileIs.read());
}
Expected behavior RandomAccessFile should not be closed when there is at least one of remaining SharedFileInputStream still being referenced(used)
The text was updated successfully, but these errors were encountered:
Describe the bug
Master
SharedFileInputStream
closes unexpectedly after GC even if some slaveSharedFileInputStream
(constructed bynewStream()
) are still being referenced.Detailed exception is
IOException: Stream Closed
To Reproduce
Steps to reproduce the behavior:
Here's a simple failing test case to reproduce the error.
I guess master
SharedFileInputStream
which is not referenced anymore callsfinalize()
andclose()
when GC works, so slaveSharedFileInputStream
also cannot access the file after that.To prove, the test case below succeeds.
Expected behavior
RandomAccessFile
should not be closed when there is at least one of remainingSharedFileInputStream
still being referenced(used)The text was updated successfully, but these errors were encountered: