This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch release-2.x in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 67c4eaaa09c3b69c44fccd31fbd1c9c956069a3b Author: Gary Gregory <[email protected]> AuthorDate: Thu Feb 25 08:03:42 2021 -0500 Revert "[LOG4J2-3026] WatchManager does not stop its ConfigurationScheduler thereby leaking a thread." This reverts commit 86ccf41d6dc999c39ddeb5af1dc0968c167c4643. --- .../java/org/apache/logging/log4j/core/util/WatchManager.java | 10 +--------- .../org/apache/logging/log4j/core/util/WatchHttpTest.java | 5 ++--- .../org/apache/logging/log4j/core/util/WatchManagerTest.java | 7 +++---- src/changes/changes.xml | 11 ++++------- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java index 48de57d..e760809 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/WatchManager.java @@ -22,7 +22,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.ServiceLoader; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -133,7 +132,7 @@ public class WatchManager extends AbstractLifeCycle { private final UUID id = LocalUUID.get(); public WatchManager(final ConfigurationScheduler scheduler) { - this.scheduler = Objects.requireNonNull(scheduler, "scheduler"); + this.scheduler = scheduler; eventServiceList = getEventServices(); } @@ -307,9 +306,6 @@ public class WatchManager extends AbstractLifeCycle { for (WatchEventService service : eventServiceList) { service.unsubscribe(this); } - if (scheduler.isStarted()) { - scheduler.stop(timeout, timeUnit); - } final boolean stopped = stop(future); setStopped(); return stopped; @@ -376,8 +372,4 @@ public class WatchManager extends AbstractLifeCycle { Source source = new Source(file); watch(source, watcher); } - - ConfigurationScheduler getScheduler() { - return scheduler; - } } diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchHttpTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchHttpTest.java index c16d525..01b837c 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchHttpTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchHttpTest.java @@ -51,7 +51,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; /** * Test the WatchManager @@ -114,7 +113,7 @@ public class WatchHttpTest { } finally { removeStub(stubMapping); watchManager.stop(); - assertTrue(watchManager.getScheduler().isStopped()); + scheduler.stop(); } } @@ -150,7 +149,7 @@ public class WatchHttpTest { } finally { removeStub(stubMapping); watchManager.stop(); - assertTrue(watchManager.getScheduler().isStopped()); + scheduler.stop(); } } diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java index 5902414..fecb2e7 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java @@ -33,7 +33,6 @@ import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import org.junit.jupiter.api.condition.OS; -import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.*; /** @@ -73,7 +72,7 @@ public class WatchManagerTest { assertNotNull(f, "File change not detected"); } finally { watchManager.stop(); - assertTrue(watchManager.getScheduler().isStopped()); + scheduler.stop(); } } @@ -106,7 +105,7 @@ public class WatchManagerTest { assertNull(f, "File change detected"); } finally { watchManager.stop(); - assertTrue(watchManager.getScheduler().isStopped()); + scheduler.stop(); } } @@ -139,7 +138,7 @@ public class WatchManagerTest { assertNull(f, "File change detected"); } finally { watchManager.stop(); - assertTrue(watchManager.getScheduler().isStopped()); + scheduler.stop(); } } diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 8c6f21f..dc548d2 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -38,13 +38,13 @@ Directly create a thread instead of using the common ForkJoin pool when initializing ThreadContextDataInjector" </action> <action issue="LOG4J2-2624" dev="mattsicker" type="fix" due-to="Tim Perry"> - Allow auto-shutdown of log4j in log4j-web to be turned off and provide a + Allow auto-shutdown of log4j in log4j-web to be turned off and provide a ServletContextListener "Log4jShutdownOnContextDestroyedListener" to stop log4j. Register the listener at the top of web.xml to ensure the shutdown happens last. </action> <action issue="LOG4J2-1606" dev="mattsicker" type="fix" due-to="Tim Perry"> - Allow auto-shutdown of log4j in log4j-web to be turned off and provide a - ServletContextListener "Log4jShutdownOnContextDestroyedListener" to stop log4j. + Allow auto-shutdown of log4j in log4j-web to be turned off and provide a + ServletContextListener "Log4jShutdownOnContextDestroyedListener" to stop log4j. Register the listener at the top of web.xml to ensure the shutdown happens last. </action> <action issue="LOG4J2-2998" dev="vy" type="fix"> @@ -83,9 +83,6 @@ <action issue="LOG4J2-3014" dev="ggregory" type="fix" due-to="Lee Breisacher, Gary Gregory"> Log4j1ConfigurationConverter on Windows produces "
" at end of every line. </action> - <action issue="LOG4J2-3026" dev="ggregory" type="fix" due-to="Gary Gregory"> - WatchManager does not stop its ConfigurationScheduler thereby leaking a thread. - </action> <!-- ADDS --> <action issue="LOG4J2-2962" dev="vy" type="add"> Enrich "map" resolver by unifying its backend with "mdc" resolver. @@ -192,7 +189,7 @@ </action> <action dev="ggregory" type="update"> Update Woodstox 5.0.3 -> 6.2.3 to match Jackson 2.12.1. - </action> + </action> <action dev="ggregory" type="update"> Update org.apache.activemq:* 5.16.0 -> 5.16.1. </action>
