Bug 48134

Summary: ImageIO Image left open when using Picture.resize() method.
Product: POI Reporter: Jeff lamb <jrlambs>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: java.jones
Priority: P2    
Version: 3.5-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   

Description Jeff lamb 2009-11-04 19:48:09 UTC
In XSSF

When calling the Picture.resize() function after adding a picture to a spreadsheet the file reference used by the imageio package is being left open.

How to repeat:  
1) Use Quick Start Code for inserting an image in an Excel sheet.
2) Run the code, having it pause just after calling the "resize" function.
3) Check the temp directory on your system.. a file is present called "imageioXXXX.tmp"
4) Allow the program to Continue/End.  (The file is now gone)

I have a J2EE project which generates spreadsheets and embeds images in them.  Each time a spreadsheet is generated a new "imageio" file is generated and held open by the java server process.  After generating enough spreadsheets the java process runs out of possible file handles.  The only way to release the hold on/remove the imageio files int he temp directory is to shut down the server and restart it.  When java ends, the files are released.

I believe the bug is located in the getImageDimension() function in the HSSFPicture.java file.  This function opens an ImageIO Image to get its dimension but never closes it.  

I've tried both version 3.2 and 3.5 and the bug is present in both.
Comment 1 Yegor Kozlov 2009-11-06 11:34:02 UTC
A very good catch, thanks!

It turns out that ImageReader must be disposed, otherwise it may continue to hold system resources indefinitely.

The fix was committed in r833527

Yegor
Comment 2 David Fisher 2009-11-10 21:20:38 UTC
*** Bug 48168 has been marked as a duplicate of this bug. ***