You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by "plutext (via GitHub)" <gi...@apache.org> on 2026/10/11 03:19:35 UTC

[PR] XGC-150: ImageLoaderRawPNG closes its stream once PNGFile has read it [xmlgraphics-commons]

plutext opened a new pull request, #34:
URL: https://github.com/apache/xmlgraphics-commons/pull/34

   Fixes [XGC-150](https://issues.apache.org/jira/browse/XGC-150).
   
   `ImageLoaderRawPNG.loadImage()` takes the `ImageInputStream` out of the session's `Source` (`XmlSourceUtil.removeStreams`) and never closes it. `PNGFile`'s constructor already reads every chunk it keeps into memory, and `getImageRawPNG()` serves the image data from those byte arrays, so the stream isn't needed once `PNGFile` is built.
   
   Left open, the PNG's file stays open until garbage collection, together with ImageIO's `imageio*.tmp` cache file where the source came from an `InputStream`. On Windows neither can be deleted after rendering (seen from docx4j, plutext/docx4j#609).
   
   The stream is now closed in a `finally`, and the stale comment is gone. `ImageLoaderRawPNGTestCase.testLoadImageClosesStream` fails without the change; the full test suite passes and checkstyle is clean.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org