TOMEE-2139 whoops, elmiminate endless loop
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e09145ea Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e09145ea Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e09145ea Branch: refs/heads/master Commit: e09145ea510cd03020ff3bc70c1711958825376a Parents: ee2b7db Author: Mark Struberg <strub...@apache.org> Authored: Mon Jun 18 14:23:47 2018 +0200 Committer: Mark Struberg <strub...@apache.org> Committed: Mon Jun 18 17:23:34 2018 +0200 ---------------------------------------------------------------------- .../tomee/jul/handler/rotating/ArchivingTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/e09145ea/tomee/tomee-juli/src/test/java/org/apache/tomee/jul/handler/rotating/ArchivingTest.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-juli/src/test/java/org/apache/tomee/jul/handler/rotating/ArchivingTest.java b/tomee/tomee-juli/src/test/java/org/apache/tomee/jul/handler/rotating/ArchivingTest.java index f2c73ee..6bd53e9 100644 --- a/tomee/tomee-juli/src/test/java/org/apache/tomee/jul/handler/rotating/ArchivingTest.java +++ b/tomee/tomee-juli/src/test/java/org/apache/tomee/jul/handler/rotating/ArchivingTest.java @@ -18,7 +18,6 @@ package org.apache.tomee.jul.handler.rotating; import org.apache.commons.io.IOUtils; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -52,13 +51,14 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -@Ignore //X TODO see TOMEE-2139 currently broken due to #f24c42e2212c575 @RunWith(Parameterized.class) public class ArchivingTest { private static final AtomicReference<WatchEvent<?>> lastEvent = new AtomicReference<>(); private static final AtomicReference<CountDownLatch> latch = new AtomicReference<>(null); + private static Thread watcherThread; + @Parameterized.Parameters(name = "{0}") public static String[][] formats() { return new String[][]{{"zip"}, {"gzip"}}; @@ -271,7 +271,12 @@ public class ArchivingTest { private static void watch(final WatchKey key) { - final Thread t = new Thread("ArchivingTest.watch") { + if (watcherThread != null) { + // tell the old watchter thread to shutdown + watcherThread.interrupt(); + } + + watcherThread = new Thread("ArchivingTest.watch") { @Override public void run() { @@ -284,7 +289,12 @@ public class ArchivingTest { continue; } + if (watcherThread != this || isInterrupted()) { + return; + } + lastEvent.set(event); + latch.get().countDown(); } @@ -297,6 +307,6 @@ public class ArchivingTest { } }; - t.start(); + watcherThread.start(); } }