From 5732785a8c5612c46c20c4c24d1f375ebb3e2e7f Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Mon, 7 Feb 2022 14:52:49 +0100 Subject: Reapply "Shutdown reconfiguration thread in a more controlled way [run-systemtest]"" --- .../container/standalone/StandaloneSubscriberFactory.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'standalone-container') diff --git a/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneSubscriberFactory.java b/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneSubscriberFactory.java index 11f799fcfd4..907c9649912 100644 --- a/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneSubscriberFactory.java +++ b/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneSubscriberFactory.java @@ -31,6 +31,7 @@ public class StandaloneSubscriberFactory implements SubscriberFactory { private final Set> configKeys; private long generation = -1L; + private volatile boolean shutdown = false; StandaloneSubscriber(Set> configKeys) { this.configKeys = configKeys; @@ -41,9 +42,7 @@ public class StandaloneSubscriberFactory implements SubscriberFactory { return generation == 0; } - @Override - public void close() { - } + @Override public void close() { shutdown = true; } @Override public Map, ConfigInstance> config() { @@ -64,9 +63,11 @@ public class StandaloneSubscriberFactory implements SubscriberFactory { if (generation != 0) { try { - while (!Thread.interrupted()) { - Thread.sleep(10000); + while (!shutdown && !Thread.interrupted()) { + Thread.sleep(100); } + if (shutdown) // Same semantics as an actual interrupt + throw new ConfigInterruptedException(new InterruptedException()); } catch (InterruptedException e) { throw new ConfigInterruptedException(e); } -- cgit v1.2.3