https://issues.apache.org/bugzilla/show_bug.cgi?id=57200

            Bug ID: 57200
           Summary: SXSSF saving fails sometimes as TempFile creation
                    fails
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: SXSSF
          Assignee: [email protected]
          Reporter: [email protected]

SXSSF creates a temporary file when its saved using the class
org.apache.poi.util.TempFile. When a tempfile is first created, the directory
name is saved within this class, in the static singleton
DefaultTempFileCreationStrategy object. This directory is only created on the
first save and its never checked if this directory still exists, as you can see
below:

        public File createTempFile(String prefix, String suffix) throws
IOException {
            // Identify and create our temp dir, if needed
            if (dir == null)
            {
                dir = new File(System.getProperty("java.io.tmpdir"),
"poifiles");
                dir.mkdir();
                if (System.getProperty("poi.keep.tmp.files") == null)
                    dir.deleteOnExit();
            }

The directory is automatically deleted when the virtual machine exits. (I
believe the directory is also created automatically when you load an xlsx using
the event api).

So, if you have two applications both loading and saving excels and you then
close one this directory is automatically deleted. Now both applications used
exactly the same temp directory. Therefore if you try to save your file in the
second application which is still open, an IOException is instead raised as it
tries to create the tmp file in the no-longer existing directory. The user
cannot save their xlsx any longer. So basically you cannot have two
applications open on a computer at the same time which load/save using POI (or
at least you can, but you have to close them both at the same time as one left
open will no longer function).

I hope my explanation is clear. Basically you need to add a check to this
function that the directory still exists and mkdir if not...

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