Project: Birt
Bug 271825 File Handle Leaks
Reported: 2009-04-09 14:01:23 | Status: verified fixed

It appears that the input stream used in FileUtil.getFileContent() is never closed. Would recommend re-factoring the code to add close methods to all of the inputstream and outputstream classes used. Here is an example: BufferedInputStream in = null; ByteArrayOutputStream out = null; try { //Uses the buffered stream to improve the performance. in = new BufferedInputStream( new FileInputStream( fileName ) ); out = new ByteArrayOutputStream( ); byte[] buf = new byte[1024]; int len; while ( ( len = in.read( buf ) ) != -1 ) { out.write( buf, 0, len ); } return out.toByteArray( ); } catch ( Exception e ) { logger.log( Level.SEVERE, "Cannot get the content of the file " + fileName, e ); //$NON-NLS-1$ } finally { if (in != null) try { in.close(); } catch (IOException e) { logger.log( Level.SEVERE, "Cannot close the inputstream to file " + fileName, e ); //$NON-NLS-1$ } if (out != null) try { out.close(); } catch (IOException e) { logger.log( Level.SEVERE, "Cannot get the outputstream for file " + fileName, e ); //$NON-NLS-1$ } } return null;

Files changed in fix:
engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/util/FileUtil.java