summaryrefslogtreecommitdiffstats
path: root/config/src
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2022-02-07 15:17:50 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2022-02-07 15:17:50 +0100
commit3144aec4cff50f200115c8ed06fa34594e7f3026 (patch)
tree989a65b028ffe966a3e1c89e57788afbd1da21dd /config/src
parent5732785a8c5612c46c20c4c24d1f375ebb3e2e7f (diff)
Throw exception if subscriber is invoked after it's closed
Diffstat (limited to 'config/src')
-rw-r--r--config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java6
-rw-r--r--config/src/main/java/com/yahoo/config/subscription/SubscriberClosedException.java11
2 files changed, 16 insertions, 1 deletions
diff --git a/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java b/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java
index de5eeb5649c..a89d60108ac 100644
--- a/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java
+++ b/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java
@@ -156,6 +156,7 @@ public class ConfigSubscriber implements AutoCloseable {
* false if this is for reconfiguration
* @return true if a config/reconfig of your system should happen
* @throws ConfigInterruptedException if thread performing this call interrupted.
+ * @throws SubscriberClosedException if subscriber is closed
*/
public boolean nextConfig(boolean isInitializing) {
return nextConfig(TimingValues.defaultNextConfigTimeout, isInitializing);
@@ -187,6 +188,7 @@ public class ConfigSubscriber implements AutoCloseable {
* false if this is for reconfiguration
* @return true if a config/reconfig of your system should happen
* @throws ConfigInterruptedException if thread performing this call interrupted.
+ * @throws SubscriberClosedException if subscriber is closed
*/
public boolean nextConfig(long timeoutMillis, boolean isInitializing) {
return acquireSnapshot(timeoutMillis, true, isInitializing);
@@ -218,6 +220,7 @@ public class ConfigSubscriber implements AutoCloseable {
* false if this is for reconfiguration
* @return true if generations for all configs have been updated.
* @throws ConfigInterruptedException if thread performing this call interrupted.
+ * @throws SubscriberClosedException if subscriber is closed
*/
public boolean nextGeneration(boolean isInitializing) {
return nextGeneration(TimingValues.defaultNextConfigTimeout, isInitializing);
@@ -249,6 +252,7 @@ public class ConfigSubscriber implements AutoCloseable {
* false if this is for reconfiguration
* @return true if generations for all configs have been updated.
* @throws ConfigInterruptedException if thread performing this call interrupted.
+ * @throws SubscriberClosedException if subscriber is closed
*/
public boolean nextGeneration(long timeoutMillis, boolean isInitializing) {
return acquireSnapshot(timeoutMillis, false, isInitializing);
@@ -271,7 +275,7 @@ public class ConfigSubscriber implements AutoCloseable {
private boolean acquireSnapshot(long timeoutInMillis, boolean requireChange, boolean isInitializing) {
boolean applyOnRestartOnly;
synchronized (monitor) {
- if (state == State.CLOSED) return false;
+ if (state == State.CLOSED) throw new SubscriberClosedException();
state = State.FROZEN;
applyOnRestartOnly = applyOnRestart;
}
diff --git a/config/src/main/java/com/yahoo/config/subscription/SubscriberClosedException.java b/config/src/main/java/com/yahoo/config/subscription/SubscriberClosedException.java
new file mode 100644
index 00000000000..f7051ab1b38
--- /dev/null
+++ b/config/src/main/java/com/yahoo/config/subscription/SubscriberClosedException.java
@@ -0,0 +1,11 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.config.subscription;
+
+/**
+ * Thrown when {@link ConfigSubscriber} is closed
+ *
+ * @author bjorncs
+ * @deprecated Will be removed in Vespa 8. Only for internal use.
+ */
+@Deprecated(forRemoval = true, since = "7")
+public class SubscriberClosedException extends RuntimeException {}