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 2017/05/31 07:38:21 UTC

[Bug 61138] New: DefaultTempFileCreationStrategy crashed in multi user mode

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

            Bug ID: 61138
           Summary: DefaultTempFileCreationStrategy crashed in multi user
                    mode
           Product: POI
           Version: 3.16-FINAL
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: POI Overall
          Assignee: dev@poi.apache.org
          Reporter: charles.fendt@diehl.com
  Target Milestone: ---

The DefaultTempFileCreationStrategy creates a sub directory in the TEMP
directory of the system

line 79: dir = new File(tmpDir, POIFILES);

But, in multi user mode, the directory /tmp/poifiles is not writeable because
owned by another user

I changed this with 
dir = new File(tmpDir, IzarTempFileCreationStrategy.POIFILES + '-' +
System.getProperty("user.name"));

And then i works fine !

-- 
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 61138] DefaultTempFileCreationStrategy crashed in multi user mode

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

--- Comment #2 from Javen O'Neal <on...@apache.org> ---
(In reply to Charles FENDT from comment #0)
> The DefaultTempFileCreationStrategy creates a sub directory in the TEMP
> directory of the system
Check out o.a.p.util.TempFile#setTempFileCreationStrategy method so that you
can plug in your own temporary file creation strategy to meet your needs by
implementing your own TempFileCreationStrategy class, as you've done here
(hopefully not modifying the DefaultTempFileCreationStrategy class, unless you
want to maintain a private fork).
There have been a few other bugs and requests on the dev mailing list for
providing more strategies, such as process-specific or thread-specific
directories, fixed-size/auto-pruning directories, and directories cleaned up on
a timer or from an explicit call rather than at JVM exit (for long-running JVM
server processes), encrypted temp files, a common folder shared among multiple
processes, with each process deleting its temp files at exit, and the last
process deleting the temp directory.

I think the documentation mentions this, but maybe not prominently enough.
DefaultTempFileCreationStrategy.java:
> * See {@link TempFileCreationStrategy} for better strategies for long-running
> * processes or limited temporary storage.
And a few strategies talked about, but not implemented, in the
TempFileCreationStrategy interface: [1]
At this point the strategies are too specific to a user's needs and the
interface is small enough to easily implement that we haven't felt the need to
add these to the POI API yet. If you want to develop some other
TempFileCreationStrategies that you think would be universally usable
(platform-independent), simple to use, and simple for us to maintain, and
agnostic of filesystems and internationalization, then feel free to contribute
a patch or pull request with unit tests. Ask if you need help.

In your example below, the user.name property may not exist, may contain
characters that are not allowed in a file path (backslash and colon come to
mind, though many other symbols and unicode could break on some file systems).

(In reply to Charles FENDT from comment #1)
> Line 128, i found a FIXME :
>         // FIXME: Java 7+: use java.nio.Files#createTempDirectory
Thanks. Apache POI still officially supports Java 6 in source and binary, so
this FIXME stays in until we officially drop support for Java 6. We should
probably have a decorator or a consistent comment string that could be searched
on to find all the code that could be written more concisely in Java 7. I'm
sure this isn't the only Java 7 fixme.

Ask around on the dev mailing list [2] or IRC channel [3] if you want to get
involved with POI.

[1]
https://poi.apache.org/apidocs/org/apache/poi/util/TempFileCreationStrategy.html
[2] http://poi.apache.org/mailinglists.html#The+POI+Developer+List
[3] https://poi.apache.org/mailinglists.html#IRC

-- 
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 61138] DefaultTempFileCreationStrategy crashed in multi user mode

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

Javen O'Neal <on...@apache.org> changed:

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

--- Comment #3 from Javen O'Neal <on...@apache.org> ---
Resolving as WONTFIX.

Users should implement their own TempFileCreationStrategy class and call
TempFile.setTempFileCreationStrategy when they need something a strategy other
than the default.

If you have any suggestions for updating the javadocs to make this clearer,
I'll happily merge those changes.

-- 
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 61138] DefaultTempFileCreationStrategy crashed in multi user mode

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

--- Comment #1 from Charles FENDT <ch...@diehl.com> ---
Line 128, i found a FIXME :
        // FIXME: Java 7+: use java.nio.Files#createTempDirectory
        final long n = random.nextLong();
        File newDirectory = new File(dir, prefix + Long.toString(n));

I change this with :
        final File newDirectory = Files.createTempDirectory(this.dir.toPath(),
prefix).toFile();

:-)

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