You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2018/04/29 09:20:44 UTC

[1/3] commons-io git commit: Ignore IntelliJ IDE files

Repository: commons-io
Updated Branches:
  refs/heads/master d08dbbfdb -> 8bb1788ae


Ignore IntelliJ IDE files


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/e9eb2d8b
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/e9eb2d8b
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/e9eb2d8b

Branch: refs/heads/master
Commit: e9eb2d8b5a858bb6810c941ee7891c3adcf9949d
Parents: d08dbbf
Author: Svetlin Zarev <sv...@abv.bg>
Authored: Sat Mar 10 20:37:30 2018 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sun Apr 29 11:10:05 2018 +0200

----------------------------------------------------------------------
 .gitignore | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/e9eb2d8b/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 127892d..a71424a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,7 @@ site-content
 /.classpath
 /.project
 /.settings/
+
+### Ignore IntelliJ files
+/.idea/
+*.iml
\ No newline at end of file


[2/3] commons-io git commit: IO-535: Thread bug in FileAlterationMonitor#stop(int) (closes #58, #36)

Posted by pa...@apache.org.
IO-535: Thread bug in FileAlterationMonitor#stop(int) (closes #58, #36)

Interrupt the thread created by FileAlterationMonitor on stop()


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/a4705cc3
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/a4705cc3
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/a4705cc3

Branch: refs/heads/master
Commit: a4705cc3c310ffb422336b319891f63eef021f1c
Parents: e9eb2d8
Author: Svetlin Zarev <sv...@abv.bg>
Authored: Sun Apr 29 11:11:00 2018 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sun Apr 29 11:16:23 2018 +0200

----------------------------------------------------------------------
 .../io/monitor/FileAlterationMonitor.java       |  1 +
 .../monitor/FileAlterationMonitorTestCase.java  | 36 ++++++++++++++++++++
 2 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/a4705cc3/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java b/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
index 3ef82df..5129f23 100644
--- a/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
+++ b/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
@@ -164,6 +164,7 @@ public final class FileAlterationMonitor implements Runnable {
         }
         running = false;
         try {
+            thread.interrupt();
             thread.join(stopInterval);
         } catch (final InterruptedException e) {
             Thread.currentThread().interrupt();

http://git-wip-us.apache.org/repos/asf/commons-io/blob/a4705cc3/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java b/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
index 200f858..1d1037b 100644
--- a/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
+++ b/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
@@ -22,9 +22,11 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
 import org.apache.commons.io.testtools.TestUtils;
 import org.junit.Test;
@@ -176,4 +178,38 @@ public class FileAlterationMonitorTestCase extends AbstractMonitorTestCase {
         }
         fail(label + " " + file + " not found");
     }
+
+    /**
+     * Test case for IO-535
+     *
+     * Verify that {@link FileAlterationMonitor#stop()} stops the created thread
+     */
+    @Test
+    public void testStopWhileWaitingForNextInterval() throws Exception {
+        final Collection<Thread> createdThreads = new ArrayList<>(1);
+        final ThreadFactory threadFactory = new ThreadFactory() {
+            private final ThreadFactory delegate = Executors.defaultThreadFactory();
+
+            @Override
+            public Thread newThread(Runnable r) {
+                final Thread thread = delegate.newThread(r);
+                thread.setDaemon(true); //do not leak threads if the test fails
+                createdThreads.add(thread);
+                return thread;
+            }
+        };
+
+        final FileAlterationMonitor monitor = new FileAlterationMonitor(1_000);
+        monitor.setThreadFactory(threadFactory);
+
+        monitor.start();
+        assertFalse(createdThreads.isEmpty());
+
+        Thread.sleep(10); // wait until the watcher thread enters Thread.sleep()
+        monitor.stop(100);
+
+        for (Thread thread : createdThreads) {
+            assertFalse("The FileAlterationMonitor did not stop the threads it created.", thread.isAlive());
+        }
+    }
 }


[3/3] commons-io git commit: IO-535: Thread bug in FileAlterationMonitor#stop(int)

Posted by pa...@apache.org.
IO-535: Thread bug in FileAlterationMonitor#stop(int)

add changes.xml entry


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/8bb1788a
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/8bb1788a
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/8bb1788a

Branch: refs/heads/master
Commit: 8bb1788ae75318bd5cca0c64893f616c82402399
Parents: a4705cc
Author: pascalschumacher <pa...@gmx.net>
Authored: Sun Apr 29 11:19:44 2018 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sun Apr 29 11:19:44 2018 +0200

----------------------------------------------------------------------
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/8bb1788a/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d143138..7f05ea0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,6 +47,9 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
     <!-- The release date is the date RC is cut -->
     <release version="2.7" date="tba" description="tba">
+      <action issue="IO-535" dev="pschumacher" type="fix" due-to="Svetlin Zarev, Anthony Raymond">
+        Thread bug in FileAlterationMonitor#stop(int)
+      </action>
       <action issue="IO-553" dev="ggregory" type="add">
         Add org.apache.commons.io.FilenameUtils.isIllegalWindowsFileName(char).
       </action>