summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@oath.com>2018-12-04 15:57:13 +0100
committerBjørn Christian Seime <bjorncs@oath.com>2018-12-04 15:57:13 +0100
commita788eceb6921aee227dd371f098f12c5b014419f (patch)
tree98908224188a76c484f80b0a1f5d5901c3cff8d9 /config
parente68ce97c2bb50784d1f10ce8bc621a3ad01aef6b (diff)
Synchronize access to 'genreration' and 'internalRedeploy' fields
Diffstat (limited to 'config')
-rw-r--r--config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java14
1 files changed, 9 insertions, 5 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 55cd77082d9..d10e7299eeb 100644
--- a/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java
+++ b/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java
@@ -29,7 +29,7 @@ import static java.util.stream.Collectors.toList;
*/
public class ConfigSubscriber {
- private Logger log = Logger.getLogger(getClass().getName());
+ private final Logger log = Logger.getLogger(getClass().getName());
private State state = State.OPEN;
protected List<ConfigHandle<? extends ConfigInstance>> subscriptionHandles = new ArrayList<>();
private final ConfigSource source;
@@ -274,8 +274,10 @@ public class ConfigSubscriber {
// This indicates the clients will possibly reconfigure their services, so "reset" changed-logic in subscriptions.
// Also if appropriate update the changed flag on the handler, which clients use.
markSubsChangedSeen(currentGen);
- internalRedeploy = internalRedeployOnly;
- generation = currentGen;
+ synchronized (monitor) {
+ internalRedeploy = internalRedeployOnly;
+ generation = currentGen;
+ }
}
return reconfigDue;
}
@@ -443,14 +445,16 @@ public class ConfigSubscriber {
* @return the current generation of configs known by this subscriber
*/
public long getGeneration() {
- return generation;
+ synchronized (monitor) {
+ return generation;
+ }
}
/**
* Whether the current config generation received by this was due to a system-internal redeploy,
* not an application package change
*/
- public boolean isInternalRedeploy() { return internalRedeploy; }
+ public boolean isInternalRedeploy() { synchronized (monitor) { return internalRedeploy; } }
/**
* Convenience interface for clients who only subscribe to one config. Implement this, and pass it to {@link ConfigSubscriber#subscribe(SingleSubscriber, Class, String)}.