Bug 57947 - "No such file or directory" after upgrade to poi-ooxml 3.12
Summary: "No such file or directory" after upgrade to poi-ooxml 3.12
Status: RESOLVED DUPLICATE of bug 57200
Alias: None
Product: POI
Classification: Unclassified
Component: OPC (show other bugs)
Version: 3.12-dev
Hardware: PC Linux
: P2 regression (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-25 08:49 UTC by laimutis.ignatavicius
Modified: 2016-03-12 17:04 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description laimutis.ignatavicius 2015-05-25 08:49:23 UTC
After poi-ooxml version upgrade from 3.10-FINAL to 3.12, tests of our software, which are running parallelly, began failing randomly:

java.io.IOException: No such file or directory
	at java.io.UnixFileSystem.createFileExclusively(Native Method)
	at java.io.File.createNewFile(File.java:1006)
	at java.io.File.createTempFile(File.java:1989)
	at org.apache.poi.util.TempFile$DefaultTempFileCreationStrategy.createTempFile(TempFile.java:105)
	at org.apache.poi.util.TempFile.createTempFile(TempFile.java:60)
	at org.apache.poi.openxml4j.opc.ZipPackage.closeImpl(ZipPackage.java:347)
	at org.apache.poi.openxml4j.opc.OPCPackage.close(OPCPackage.java:426)


We found changes in ZipPackage.closeImpl():

poi-ooxml 3.10-FINAL:
org.apache.poi.openxml4j.opc.ZipPackage.closeImpl()
line 343:  File tempFile = File.createTempFile(generateTempFileName(FileHelper.getDirectory(targetFile)), ".tmp");

o poi-ooxml 3.12:
org.apache.poi.openxml4j.opc.ZipPackage.closeImpl()
line 347:   File tempFile = TempFile.createTempFile(generateTempFileName(FileHelper.getDirectory(targetFile)), ".tmp");

In TempFile.createTempFile method temp files are creating in 'poifiles' subdirectory, which is marked with "deleteOnExit".

When multiple applications in same computer are running simultaneously, some of them began failing.

We tried to set system property "poi.keep.tmp.files" values where possible, but we are still getting failures...

Our recommendations:
a) not to try delete poifiles temp files directory that is used by multiple applications with poi integration; or
b) create random poifilesxxxx temp files subdirectories for each application with poi integration.
Comment 1 Dominik Stadler 2015-05-25 19:43:25 UTC
The poi.keep.tmp.files property should prevent POI from cleaning those files completely, so it is strange that it does not solve the problem completely for you. Either some other process is removing this directory on your setup, e.g. temp-file-cleanup scripts or there are still POI-related processes running without that system property being set.

In addition, according to how the deleteOnExit-hook in the JVM is implemented and the javadoc of File.delete(), it should suffice to put an unrelated file into the poifiles-directory to prevent it from being removed. Can you try if that is a workaround in your case?
Comment 2 htung 2015-08-11 06:15:07 UTC
Should this be fused with #57200 as duplicate?  This bug makes it clear that the problem extends beyond the SXSSF component, but it's almost certainly the same bug.
Comment 3 Dominik Stadler 2016-03-12 15:38:38 UTC
I am closing this as duplicate of bug 57200, we likely will not remove the poifiles directory in the future to avoid these types of problems when multiple applications are running in parallel.

*** This bug has been marked as a duplicate of bug 57200 ***