Ticket #856 (closed Bug: fixed)
[PATCH] Possible resource leak in ImagePreSaveHook.writeJpeg()
|Reported by:||Matthias Bauer <matthias.bauer.drs@…>||Owned by:||somebody|
org.outerj.daisy.presavehook.image.ImagePreSaveHook?.writeJpeg() has some issues:
(1) There is probably a resource leak in that function, because the ImageWriter? needs to be a dispose()-d explicitly after use (at least according to the ImageIO documentation).
(2) writer.getDefaultWriteParam() is not guaranteed to return an instance of JPEGImageWriteParam. One should use ImageWriteParam? instead. (The JPEG-Writer of the JAI-ImageIO package for example returns an instance of its own parameter class, which is a child of ImageWriteParam?, but not one of JPEGImageWriteParam.)
(3) One should explicitly close the ImageOutputStream?. Some writers will return incomplete output, if the stream isn't flushed or closed.
(While we are at it, one might also want to get rid of the obsoleted com.sun.image.codec.jpeg stuff. See ImagePreSaveHook?.02-Fix-Obsoletes.patch for this.)