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 2014/11/11 18:06:34 UTC

[Bug 57200] New: SXSSF saving fails sometimes as TempFile creation fails

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: dev@poi.apache.org
          Reporter: info@opendoorlogistics.com

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


[Bug 57200] SXSSF saving fails sometimes as TempFile creation fails

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

Philip Welch <in...@opendoorlogistics.com> changed:

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

--- Comment #2 from Philip Welch <in...@opendoorlogistics.com> ---
Thanks - I'll take a look at how you plug different temp file strategies in (do
you have a handy link?) as a fix for my own application. 

However the default behaviour of POI will break whenever two applications are
open using it so presumably this needs to be fixed within POI itself going
forward. Particularly as this could even be two completely different
applications which you wouldn't ever expect to interact.

The default behaviour should be a unique tmp directory per virtual machine
using POI to ensure no unexpected interactions occur between POIs in different
virtual machines.

-- 
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 57200] SXSSF saving fails sometimes as TempFile creation fails

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

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

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

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
the temp file strategy is pluggable, could you not provide your own to handle
the case of multiple JVMs starting/stopping and tidying up after each other?

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