diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-02-04 13:48:06 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-02-04 13:48:06 +0100 |
commit | 17dfbf4625386d1f37313f2da9f6f9b4c7e96c4c (patch) | |
tree | aed2ab71aba51a593d63f6962e03bca29fc3c33e /standalone-container | |
parent | bbbfcfa38c01142e8fd56b48fb08da30cd38383d (diff) |
Shutdown reconfiguration thread in a more controlled way
Use interrupts is a horrible mechanism as we cannot control which part of the code receives the signal.
Diffstat (limited to 'standalone-container')
-rw-r--r-- | standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneSubscriberFactory.java | 11 |
1 files changed, 6 insertions, 5 deletions
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<ConfigKey<ConfigInstance>> configKeys; private long generation = -1L; + private volatile boolean shutdown = false; StandaloneSubscriber(Set<ConfigKey<ConfigInstance>> 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<ConfigKey<ConfigInstance>, 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); } |