From 5d570854ef77d6b474fc0ebf50cd002415c170e1 Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Wed, 10 Jan 2018 12:55:25 +0100 Subject: Set volatile, add comment --- .../node/admin/util/ConfigServerHttpRequestExecutor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'node-admin') diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java index 64de416e3dc..7b7de0e7417 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java @@ -50,7 +50,15 @@ public class ConfigServerHttpRequestExecutor implements AutoCloseable { Executors.newScheduledThreadPool(1, ThreadFactoryFactory.getDaemonThreadFactory("http-client-refresher")); private final List configServerHosts; - private SelfCloseableHttpClient client; + /** + * The 'client' will be periodically re-created by clientRefresherScheduler if we provide keyStoreOptions + * or trustStoreOptions. This is needed because the key/trust stores are updated outside of node-admin, + * but we want to use the most recent store. + * + * The 'client' reference must be volatile because it is set and read in different threads, and visibility + * of changes is only guaranteed for volatile variables. + */ + private volatile SelfCloseableHttpClient client; public static ConfigServerHttpRequestExecutor create( Collection configServerUris, Optional keyStoreOptions, Optional trustStoreOptions) { -- cgit v1.2.3