diff options
Diffstat (limited to 'config')
4 files changed, 36 insertions, 5 deletions
diff --git a/config/abi-spec.json b/config/abi-spec.json index 844835ae1c5..e94749cfba8 100644 --- a/config/abi-spec.json +++ b/config/abi-spec.json @@ -297,5 +297,16 @@ "fields": [ "public final java.lang.String payload" ] + }, + "com.yahoo.config.subscription.SubscriberClosedException": { + "superClass": "java.lang.RuntimeException", + "interfaces": [], + "attributes": [ + "public" + ], + "methods": [ + "public void <init>()" + ], + "fields": [] } }
\ No newline at end of file diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index bc38eddc0dd..29c68d49da7 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -196,15 +196,20 @@ GetConfig::Main() schema = schemaString; } if (debugging) { - printf("Using schema in %s\n", schema.c_str()); + printf("Using schema from '%s'\n", schema.c_str()); } std::ifstream is; is.open(schema); std::string item; - while (std::getline(is, item)) { - if (item.find("namespace=") == std::string::npos) { - defSchema.push_back(item); + if (is.is_open()) { + while (std::getline(is, item)) { + if (item.find("namespace=") == std::string::npos) { + defSchema.push_back(item); + } } + } else { + fprintf(stderr, "Could not open schema file '%s'\n", schema.c_str()); + return 1; } is.close(); 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 {} |