]> source.dussan.org Git - poi.git/commitdiff
try to find out temp file errors on maven build
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 5 Jun 2016 16:49:18 +0000 (16:49 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 5 Jun 2016 16:49:18 +0000 (16:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1746932 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/util/TempFile.java

index b228d237d1d6139a65f6a05ac99f5b779e27a443..44f461379ca42b8a34e7cf9e3d36cc70dc49eaf6 100644 (file)
@@ -96,20 +96,24 @@ public final class TempFile {
         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");
-                if(!dir.exists()) {
-                    if(!dir.mkdirs()) {
-                        throw new IOException("Could not create temporary directory '" + dir + "'");
-                    }
+                String tmpDir = System.getProperty(JAVA_IO_TMPDIR);
+                if (tmpDir == null) {
+                    throw new IOException("Systems temporary directory not defined - set the -D"+JAVA_IO_TMPDIR+" jvm property!");
                 }
+                dir = new File(tmpDir, "poifiles");
             }
 
+             if (!(dir.exists() || dir.mkdirs()) || !dir.isDirectory()) {
+                throw new IOException("Could not create temporary directory '" + dir + "'");
+            }
+            
             // Generate a unique new filename 
             File newFile = File.createTempFile(prefix, suffix, dir);
 
             // Set the delete on exit flag, unless explicitly disabled
-            if (System.getProperty("poi.keep.tmp.files") == null)
+            if (System.getProperty("poi.keep.tmp.files") == null) {
                 newFile.deleteOnExit();
+            }
 
             // All done
             return newFile;