Author: fanningpj
Date: Wed May  8 17:24:41 2024
New Revision: 1917583

URL: http://svn.apache.org/viewvc?rev=1917583&view=rev
Log:
add back check for if dir already exists

Modified:
    
poi/trunk/poi/src/main/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java?rev=1917583&r1=1917582&r2=1917583&view=diff
==============================================================================
--- 
poi/trunk/poi/src/main/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java
 (original)
+++ 
poi/trunk/poi/src/main/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java
 Wed May  8 17:24:41 2024
@@ -77,15 +77,23 @@ public class DefaultTempFileCreationStra
         // Create our temp dir only once by double-checked locking
         // The directory is not deleted, even if it was created by this 
TempFileCreationStrategy
         if (dir == null) {
+            final String tmpDir = System.getProperty(JAVA_IO_TMPDIR);
+            if (tmpDir == null) {
+                throw new IOException("System's temporary directory not 
defined - set the -D" + JAVA_IO_TMPDIR + " jvm property!");
+            }
             dirLock.lock();
             try {
                 if (dir == null) {
-                    String tmpDir = System.getProperty(JAVA_IO_TMPDIR);
-                    if (tmpDir == null) {
-                        throw new IOException("System's temporary directory 
not defined - set the -D" + JAVA_IO_TMPDIR + " jvm property!");
-                    }
                     Path dirPath = Paths.get(tmpDir, POIFILES);
-                    dir = Files.createDirectories(dirPath).toFile();
+                    File fileDir = dirPath.toFile();
+                    if (fileDir.exists()) {
+                        if (!fileDir.isDirectory()) {
+                            throw new IOException("Could not create temporary 
directory. '" + fileDir + "' exists but is not a directory.");
+                        }
+                        dir = fileDir;
+                    } else {
+                        dir = Files.createDirectories(dirPath).toFile();
+                    }
                 }
             } finally {
                 dirLock.unlock();



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to