Skip to content

Commit

Permalink
Simplify initialization of Settings
Browse files Browse the repository at this point in the history
There was a weird circular class-loading dependency between Settings and
Settings.Builder that could result in ClassLoader deadlock if multiple
threads trigger class-loading of Settings at the same time.

Signed-off-by: Michael Froh <froh@amazon.com>
  • Loading branch information
msfroh committed Sep 22, 2023
1 parent 38db1df commit e7b2082
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
@PublicApi(since = "1.0.0")
public final class Settings implements ToXContentFragment {

public static final Settings EMPTY = new Builder().build();
public static final Settings EMPTY = new Settings(Collections.emptyMap(), null);

/** The raw settings from the full key to raw string value. */
private final Map<String, Object> settings;
Expand Down Expand Up @@ -757,7 +757,7 @@ public Set<String> keySet() {
@PublicApi(since = "1.0.0")
public static class Builder {

public static final Settings EMPTY_SETTINGS = new Builder().build();
public static final Settings EMPTY_SETTINGS = Settings.EMPTY;

// we use a sorted map for consistent serialization when using getAsMap()
private final Map<String, Object> map = new TreeMap<>();
Expand Down

0 comments on commit e7b2082

Please sign in to comment.