This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new 39b6e211 Reuse FileUtils and PathUtils
39b6e211 is described below

commit 39b6e2110a1f669a7ed7b77a897e8710de577ca6
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Wed Jul 19 12:23:58 2023 -0400

    Reuse FileUtils and PathUtils
---
 .../java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java     | 5 ++---
 .../src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java | 3 ++-
 .../commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java     | 3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java
 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java
index 4b0bb655..5bc934e7 100644
--- 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java
+++ 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java
@@ -20,6 +20,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Random;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.vfs2.FileObject;
@@ -173,9 +174,7 @@ public class DefaultFileReplicator extends 
AbstractVfsComponent implements FileR
     @Override
     public void init() throws FileSystemException {
         if (tempDir == null) {
-            final String baseTmpDir = System.getProperty("java.io.tmpdir");
-
-            tempDir = new File(baseTmpDir, "vfs_cache").getAbsoluteFile();
+            tempDir = new File(FileUtils.getTempDirectoryPath(), 
"vfs_cache").getAbsoluteFile();
         }
 
         filecount = RANDOM.nextInt() & MASK;
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java
index ac746d50..e2f7e68c 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java
@@ -31,6 +31,7 @@ import java.util.Objects;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.function.Uncheck;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.commons.vfs2.FileSelectInfo;
@@ -154,7 +155,7 @@ public abstract class BaseFilterTest {
      * @return java.io.tmpdir
      */
     protected static File getTempDir() {
-        return new File(System.getProperty("java.io.tmpdir"));
+        return FileUtils.getTempDirectory();
     }
 
     /**
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java
index e549005f..3f0a8317 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java
@@ -36,6 +36,7 @@ import java.util.TreeMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.commons.io.file.PathUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.vfs2.AbstractProviderTestConfig;
 import org.apache.commons.vfs2.FileObject;
@@ -490,7 +491,7 @@ abstract class AbstractSftpProviderTestCase extends 
AbstractProviderTestConfig {
             return;
         }
         // System.setProperty("vfs.sftp.sshdir", getTestDirectory() + 
"/../vfs.sftp.sshdir");
-        final Path tmpDir = Paths.get(System.getProperty("java.io.tmpdir"));
+        final Path tmpDir = PathUtils.getTempDirectory();
         Server = SshServer.setUpDefaultServer();
         Server.setSessionFactory(sessionFactory);
         Server.setPort(0);

Reply via email to