You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2022/03/11 00:44:32 UTC

[Bug 65949] New: SXSSFWorkbook write method does not close underlying XSSFWorkbook temp file

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: dev@poi.apache.org
          Reporter: jbaek.in@gmail.com
  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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65949] SXSSFWorkbook write method does not close underlying XSSFWorkbook temp file

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65949

--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
That code change was deliberate as far as I know. Could you change your code to
close the SXSSFWorkbook and also to call dispose on the SXSSFWorkbook after you
do the write?

This seems to be related to https://github.com/apache/poi/pull/312

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 65949] SXSSFWorkbook write method does not close underlying XSSFWorkbook temp file

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65949

jbaek <jb...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #2 from jbaek <jb...@gmail.com> ---

after adding _wb.close(); and tested with poi source i found below error.

So close this report.

> Task :poi-ooxml:test

TestSXSSFWorkbook > bug53515() FAILED
    org.opentest4j.AssertionFailedError at TestSXSSFWorkbook.java:354           
        Caused by: java.io.IOException at TestSXSSFWorkbook.java:354

TestSXSSFBugs >
bug60197_NamedRangesReferToCorrectSheetWhenSheetOrderIsChanged() FAILED         
    java.lang.RuntimeException at SXSSFITestDataProvider.java:76
        Caused by: java.io.IOException at POIXMLDocument.java:215

TestSXSSFBugs > testWriteDocumentTwice() FAILED
    java.io.IOException at POIXMLDocument.java:215

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org