ASF Bugzilla – Attachment 29278 Details for
Bug 53780
memory, temporary file and file handle leak in SXSSF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
patch to fix leaks of memory and temporary files
patch.txt (text/plain), 3.25 KB, created by
David Pletcher
on 2012-08-24 22:46:04 UTC
(
hide
)
Description:
patch to fix leaks of memory and temporary files
Filename:
MIME Type:
Creator:
David Pletcher
Created:
2012-08-24 22:46:04 UTC
Size:
3.25 KB
patch
obsolete
>Index: src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (revision 1377130) >+++ src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (working copy) >@@ -1364,4 +1364,12 @@ > } > return -1; > } >+ >+ /** >+ * Cleans up (deletes) the temporary file that backed this sheet on disk. >+ * @return true if the file was deleted, false if it wasn't. >+ */ >+ boolean cleanup() { >+ return _writer.cleanup(); >+ } > } >Index: src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java (revision 1377130) >+++ src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java (working copy) >@@ -57,7 +57,6 @@ > */ > public File createTempFile()throws IOException { > File fd = File.createTempFile("poi-sxssf-sheet", ".xml"); >- fd.deleteOnExit(); > return fd; > } > >@@ -302,4 +301,12 @@ > _out.write(chars, last, length - last); > } > } >+ >+ /** >+ * Cleans up (deletes) the temporary file that backed this sheet on disk. >+ * @return true if the file was deleted, false if it wasn't. >+ */ >+ boolean cleanup() { >+ return _fd.delete(); >+ } > } >Index: src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java (revision 1377130) >+++ src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java (working copy) >@@ -760,14 +760,29 @@ > > //Save the template > File tmplFile = File.createTempFile("poi-sxssf-template", ".xlsx"); >- tmplFile.deleteOnExit(); >- FileOutputStream os = new FileOutputStream(tmplFile); >- _wb.write(os); >- os.close(); >+ try >+ { >+ FileOutputStream os = new FileOutputStream(tmplFile); >+ try >+ { >+ _wb.write(os); >+ } >+ finally >+ { >+ os.close(); >+ } > >- //Substitute the template entries with the generated sheet data files >- injectData(tmplFile, stream); >- tmplFile.delete(); >+ //Substitute the template entries with the generated sheet data files >+ injectData(tmplFile, stream); >+ } >+ finally >+ { >+ tmplFile.delete(); >+ for (SXSSFSheet sheet : _sxFromXHash.keySet()) >+ { >+ sheet.cleanup(); >+ } >+ } > } > > /** >Index: src/ooxml/java/org/apache/poi/xssf/streaming/GZIPSheetDataWriter.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/streaming/GZIPSheetDataWriter.java (revision 1377130) >+++ src/ooxml/java/org/apache/poi/xssf/streaming/GZIPSheetDataWriter.java (working copy) >@@ -37,7 +37,6 @@ > */ > public File createTempFile()throws IOException { > File fd = File.createTempFile("poi-sxssf-sheet-xml", ".gz"); >- fd.deleteOnExit(); > return fd; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 53780
: 29278 |
29285