https://bz.apache.org/bugzilla/show_bug.cgi?id=65949

            Bug ID: 65949
           Summary: SXSSFWorkbook write method does not close underlying
                    XSSFWorkbook temp file
           Product: POI
           Version: 5.1.0-FINAL
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SXSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Hi

I happen to lookup the source code of SXSSFWorkbook.write. 

and found the undering workbook is not closed properly.


POI TRUNK: 
https://svn.apache.org/repos/asf/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
--------------


    public void write(OutputStream stream) throws IOException {
        flushSheets();

        //Save the template
        File tmplFile = TempFile.createTempFile("poi-sxssf-template", ".xlsx");
        boolean deleted;
        try {
            try (FileOutputStream os = new FileOutputStream(tmplFile)) {
                _wb.write(os);
//HERE SHOULD CLOSE??? _wb.close();
            }

            //Substitute the template entries with the generated sheet data
files
            try (ZipSecureFile zf = new ZipSecureFile(tmplFile);
                 ZipFileZipEntrySource source = new ZipFileZipEntrySource(zf))
{
                injectData(source, stream);
            }
        } finally {
            deleted = tmplFile.delete();
        }
        if (!deleted) {
            throw new IOException("Could not delete temporary file after
processing: " + tmplFile);
        }
    }
---------------



I looked up the previous source code and found from POI 4.0.0
SXSSFWorkbook.write does not close underlying workbook.

POI 4.0.0 :
https://github.com/apache/poi/blob/333b47391399898dca8e91366d316c5a8aeb1809/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java#L930


POI 3.17 closed the outputstream :
https://github.com/apache/poi/blob/ab700dc2ae3a880f66a10075cbf1a502da928afb/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java#L929

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to