You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/09/11 14:23:44 UTC

[commons-io] branch master updated (18a2406 -> 3d1980b)

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

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


    from 18a2406  ThreadMonitor.sleep(Duration) ignores nanoseconds.
     new d990ec3  Add FileUtils.current().
     new 9b781b7  Javadoc.
     new ddb1b10  Split out negative duration test.
     new 3d1980b  Test that the file exists one last time on exit.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                              |  3 +++
 src/main/java/org/apache/commons/io/FileUtils.java   | 14 +++++++++++++-
 .../java/org/apache/commons/io/file/PathUtils.java   |  2 +-
 .../apache/commons/io/FileUtilsWaitForTestCase.java  | 20 +++++++++++---------
 4 files changed, 28 insertions(+), 11 deletions(-)

[commons-io] 04/04: Test that the file exists one last time on exit.

Posted by gg...@apache.org.
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-io.git

commit 3d1980bc6dce0fd80ccceb9cef807ac36d799de4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 11 07:23:41 2021 -0700

    Test that the file exists one last time on exit.
---
 src/main/java/org/apache/commons/io/file/PathUtils.java           | 2 +-
 src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java
index 44f04e7..2136ac7 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -1107,7 +1107,7 @@ public final class PathUtils {
                 Thread.currentThread().interrupt();
             }
         }
-        return true;
+        return Files.exists(file, options);
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
index 544d423..a751064 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
@@ -48,7 +48,7 @@ public class FileUtilsWaitForTestCase {
         final CountDownLatch started = new CountDownLatch(1);
         final Thread thread1 = new Thread(() -> {
             started.countDown();
-            FileUtils.waitFor(FileUtils.current(), 2);
+            assertTrue(FileUtils.waitFor(FileUtils.current(), 4));
             wasInterrupted.set(Thread.currentThread().isInterrupted());
         });
         thread1.start();

[commons-io] 01/04: Add FileUtils.current().

Posted by gg...@apache.org.
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-io.git

commit d990ec36a4d3b570dba499834bbdb8bb22dd659d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 11 07:07:56 2021 -0700

    Add FileUtils.current().
---
 src/changes/changes.xml                                  |  3 +++
 src/main/java/org/apache/commons/io/FileUtils.java       | 12 ++++++++++++
 .../org/apache/commons/io/FileUtilsWaitForTestCase.java  | 16 +++++++---------
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a4450a2..6f3c71b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -172,6 +172,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add org.apache.commons.io.input.Tailer.getDelayDuration().
       </action>
+      <action dev="ggregory" type="add" due-to="Gary Gregory">
+        Add FileUtils.current().
+      </action>
       <!-- UPDATE -->
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Update FileEntry to use FileTime instead of long for file time stamps.
diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index fd5438d..227c994 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -1116,6 +1116,17 @@ public class FileUtils {
     }
 
     /**
+     * Gets the current directory.
+     *
+     * @return the current directory.
+     *
+     * @since 2.12.0
+     */
+    public static File current() {
+        return PathUtils.current().toFile();
+    }
+
+    /**
      * Decodes the specified URL as per RFC 3986, i.e. transforms
      * percent-encoded octets to characters by decoding with the UTF-8 character
      * set. This function is primarily intended for usage with
@@ -3601,4 +3612,5 @@ public class FileUtils {
     public FileUtils() { //NOSONAR
 
     }
+
 }
diff --git a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
index 1068f24..eea7bf7 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
@@ -18,7 +18,6 @@ package org.apache.commons.io;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.io.File;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -35,25 +34,24 @@ public class FileUtilsWaitForTestCase {
 
     @Test
     public void testWaitFor() {
-        FileUtils.waitFor(new File(""), -1);
-        FileUtils.waitFor(new File(""), 2);
+        FileUtils.waitFor(FileUtils.current(), -1);
+        FileUtils.waitFor(FileUtils.current(), 2);
     }
 
     @Test
     public void testWaitForInterrupted() throws InterruptedException {
         final AtomicBoolean wasInterrupted = new AtomicBoolean(false);
         final CountDownLatch started = new CountDownLatch(1);
-        final Runnable thread = () -> {
+        final Thread thread1 = new Thread(() -> {
             started.countDown();
-            FileUtils.waitFor(new File(""), 2);
-            wasInterrupted.set( Thread.currentThread().isInterrupted());
-        };
-        final Thread thread1 = new Thread(thread);
+            FileUtils.waitFor(FileUtils.current(), 2);
+            wasInterrupted.set(Thread.currentThread().isInterrupted());
+        });
         thread1.start();
         started.await();
         thread1.interrupt();
         thread1.join();
-        assertTrue( wasInterrupted.get() );
+        assertTrue(wasInterrupted.get());
     }
 
 }

[commons-io] 03/04: Split out negative duration test.

Posted by gg...@apache.org.
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-io.git

commit ddb1b10c4c61c0cb8692dce73a58bf1ac4fbda94
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 11 07:16:30 2021 -0700

    Split out negative duration test.
---
 src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
index eea7bf7..544d423 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
@@ -35,7 +35,11 @@ public class FileUtilsWaitForTestCase {
     @Test
     public void testWaitFor() {
         FileUtils.waitFor(FileUtils.current(), -1);
-        FileUtils.waitFor(FileUtils.current(), 2);
+    }
+
+    @Test
+    public void testWaitForNegativeDuration() {
+        FileUtils.waitFor(FileUtils.current(), -1);
     }
 
     @Test

[commons-io] 02/04: Javadoc.

Posted by gg...@apache.org.
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-io.git

commit 9b781b771966625b2748ceffb58c87526546232b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 11 07:13:27 2021 -0700

    Javadoc.
---
 src/main/java/org/apache/commons/io/FileUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 227c994..3fea3b1 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -3176,7 +3176,7 @@ public class FileUtils {
     /**
      * Waits for the file system to propagate a file creation, with a timeout.
      * <p>
-     * This method repeatedly tests {@link File#exists()} until it returns
+     * This method repeatedly tests {@link Files#exists(Path, LinkOption...)} until it returns
      * true up to the maximum time specified in seconds.
      * </p>
      *