Skip to content

Commit

Permalink
Simplify initialization of Settings (opensearch-project#10194)
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>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
  • Loading branch information
msfroh authored and shiv0408 committed Apr 25, 2024
1 parent cc383df commit 7b4db49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix broken backward compatibility from 2.7 for IndexSorted field indices ([#10045](https://github.com/opensearch-project/OpenSearch/pull/10045))
- Fix concurrent search NPE when track_total_hits, terminate_after and size=0 are used ([#10082](https://github.com/opensearch-project/OpenSearch/pull/10082))
- Fix remove ingest processor handing ignore_missing parameter not correctly ([10089](https://github.com/opensearch-project/OpenSearch/pull/10089))
- Fix circular dependency in Settings initialization ([10194](https://github.com/opensearch-project/OpenSearch/pull/10194))

### Security

Expand Down
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 7b4db49

Please sign in to comment.