|
@@ -690,14 +690,17 @@ public final class Settings implements ToXContentFragment {
|
|
|
|
|
|
/** Returns the fully qualified setting names contained in this settings object. */
|
|
|
public Set<String> keySet() {
|
|
|
- synchronized (keys) {
|
|
|
- if (keys.get() == null) {
|
|
|
- if (secureSettings == null) {
|
|
|
- keys.set(settings.keySet());
|
|
|
- } else {
|
|
|
- Stream<String> stream = Stream.concat(settings.keySet().stream(), secureSettings.getSettingNames().stream());
|
|
|
- // uniquify, since for legacy reasons the same setting name may exist in both
|
|
|
- keys.set(Collections.unmodifiableSet(stream.collect(Collectors.toSet())));
|
|
|
+ if (keys.get() == null) {
|
|
|
+ synchronized (keys) {
|
|
|
+ // Check that the keys are still null now that we have acquired the lock
|
|
|
+ if (keys.get() == null) {
|
|
|
+ if (secureSettings == null) {
|
|
|
+ keys.set(settings.keySet());
|
|
|
+ } else {
|
|
|
+ Stream<String> stream = Stream.concat(settings.keySet().stream(), secureSettings.getSettingNames().stream());
|
|
|
+ // uniquify, since for legacy reasons the same setting name may exist in both
|
|
|
+ keys.set(Collections.unmodifiableSet(stream.collect(Collectors.toSet())));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|