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 2015/03/05 13:07:45 UTC

[Bug 57666] New: SXSSFWorkbook.dispose() does not delete temp xml files of sheets copied from an existing XSSFWorkbook at construction time

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

            Bug ID: 57666
           Summary: SXSSFWorkbook.dispose() does not delete temp xml files
                    of sheets copied from an existing XSSFWorkbook at
                    construction time
           Product: POI
           Version: 3.11-FINAL
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SXSSF
          Assignee: dev@poi.apache.org
          Reporter: yaniv@kundas.net

Any sheets copied from an existing workbook when constructing a SXSSFWorkbook
are not deleted by the dispose() method.

For example, assume "existingWorkbook" contains n sheets:

    SXSSFWorkbook wb = SXSSFWorkbook(existingWorkbook);
    wb.createSheet("New");
    wb.dispose();

After calling the constructor, a temporary xml file is created for each new
sheet copied from an existing sheet.
After calling wb.createSheet a temporary xml file is created for the fresh
sheet.
After calling dispose(), only the temporary xml file created by createSheet()
will be deleted.

I didn't provide a unit test since it's hard to to check for the internally
created temp files, and also because File.delete() is not guaranteed to be
actually deleted after returning with "true" because the file system operation
might be async.

-- 
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 57666] SXSSFWorkbook.dispose() does not delete temp xml files of sheets copied from an existing XSSFWorkbook at construction time

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

--- Comment #2 from Yaniv Kunda <ya...@kundas.net> ---
(In reply to Nick Burch from comment #1)
> Any chance of a patch to fix this?

Actually, I've looked further into this and the problem might be different:
In my case (and I failed to mentioned this), after creating the SXSSFWorkbook
using the existing XSSFWorkbook, I've deleted the sheet created as a copy from
the XSSFWorkbook, using removeSheetAt().

So the problem might in fact be that removeSheetAt() does not delete its
writer's temp file.

-- 
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 57666] SXSSFWorkbook.dispose() does not delete temp xml files of sheets copied from an existing XSSFWorkbook at construction time

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

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Nick Burch <ap...@gagravarr.org> ---
Thanks, I've added the dispose call on remove in r1676833.

-- 
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 57666] SXSSFWorkbook.dispose() does not delete temp xml files of sheets copied from an existing XSSFWorkbook at construction time

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

--- Comment #4 from Yaniv Kunda <ya...@kundas.net> ---
I also found a workaround applicable for my situation -

This is my problematic code:

            // open a template with a single sheet
            XSSFWorkbook template = new XSSFWorkbook("data/template.xlsx");
            SXSSFWorkbook wb = new SXSSFWorkbook(template);
            try {
                Sheet templateSheet = template.getSheetAt(0);
                // read some stuff from the template
                ...

                // create new sheet
                Sheet sheet = wb.createSheet("Data");

                // remove sheet copied from template
                wb.removeSheetAt(0);

                // fill the new sheet with data
                ...

                wb.write(out);
            } finally {
                wb.dispose();
            }

The workaround is to call wb.dispose() before creating the new sheet.

-- 
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 57666] SXSSFWorkbook.dispose() does not delete temp xml files of sheets copied from an existing XSSFWorkbook at construction time

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

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Any chance of a patch to fix this?

-- 
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 57666] SXSSFWorkbook.dispose() does not delete temp xml files of sheets copied from an existing XSSFWorkbook at construction time

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

--- Comment #3 from Yaniv Kunda <ya...@kundas.net> ---
I don't have a proper environment for patching right now, but I would change
SXSSFWorkbook.removeSheetAt(int) from

    public void removeSheetAt(int index)
    {
        XSSFSheet xSheet=_wb.getSheetAt(index);
        _wb.removeSheetAt(index);
        deregisterSheetMapping(xSheet);
    }

to

    public void removeSheetAt(int index)
    {
        XSSFSheet xSheet=_wb.getSheetAt(index);
        _wb.removeSheetAt(index);
        SXSSFSheet sxSheet = getSXSSFSheet(xSheet);
        sxSheet.dispose();
        deregisterSheetMapping(xSheet);
    }

-- 
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