Skip to content

do not close the stream inside CCITTFactory.extractFromTiff method - #501

Closed
valerybokov wants to merge 1 commit into
apache:trunkfrom
valerybokov:fix-CCITTFactory.extractFromTiff
Closed

do not close the stream inside CCITTFactory.extractFromTiff method#501
valerybokov wants to merge 1 commit into
apache:trunkfrom
valerybokov:fix-CCITTFactory.extractFromTiff

Conversation

@valerybokov

Copy link
Copy Markdown

This code doesn't throw an IOException or other error, but the code structure is incorrect. It is fragile. We write data to the output stream in the extractFromTiff method, close it, and then read the data from outside in the createFromRandomAccessImpl method. But the stream is closed. We can do it only because this is ByteArrayOutputStream. If we change the stream type then there will be an exception.

@THausherr

Copy link
Copy Markdown
Contributor

Thank you. It turns out I introduced this in 2014 (before that the close was needed). I didn't use the PR, I remove the close manually, hopefully that is the same.

@valerybokov
valerybokov deleted the fix-CCITTFactory.extractFromTiff branch August 28, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants