Bug 48134 - ImageIO Image left open when using Picture.resize() method.
Summary: ImageIO Image left open when using Picture.resize() method.
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.5-FINAL
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
: 48168 (view as bug list)
Depends on:
Reported: 2009-11-04 19:48 UTC by Jeff lamb
Modified: 2009-11-10 21:20 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Jeff lamb 2009-11-04 19:48:09 UTC

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

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