Closed S-Gaertner closed 7 months ago
Good catch! I was under the assumption, that the RandomAccessReadBuffer would close the "underlying" inputStream. Will change that.
Version 1.2.1 is in the making.
Wow, that was quick! Thanks a lot 👍
1.2.1 was released and should land in maven central within the next 1-2 hours. With such a specific error description, it was easy to fix.
Unfortunately your fix does not work. I believe now you ask your InputStreamSupplier
s to get yet another InputStream
in lines 393 and 395, which you immediately close. However, the InputStream
s you got in the immediately preceding lines are still not closed.
You are right. I was too quick. get() does not just "get" the stream, but actually creates it, since it's a Supplier. Version 1.2.2 should fix it properly now. :-)
Thank you again for your stunningly quick resolution! I can confirm that the fix works now, therefore I'll close this issue.
InputStream
s opened in the following lines ofPdfComparator
are not closed anywhere:Especially, the
RandomAccessReadBuffer
s in lines 392 and 393, where thoseInputStream
s are used, do not close their underlyingInputStream
s upon their own closure.This can lead to resource leaks and file locking, depending on the platform-specific
InputStream
implementation. At some point in time the garbage collector will close the left overInputStream
s, which can lead to undesirable behaviour due to its non-deterministic nature.In case
InputStream
s are created internally in the library, they should be closed when not needed anymore. The only case where theInputStream
s should not be closed is when they are created externally by the user and passed into the library using thePdfComparator(final InputStream expectedPdfIS, final InputStream actualPdfIS)
constructor.