Skip to content

Commit

Permalink
Reverts changes made to Settings class
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
DarshitChanpura committed Sep 27, 2023
1 parent 6e1f9f0 commit 09f4339
Showing 1 changed file with 3 additions and 56 deletions.
59 changes: 3 additions & 56 deletions server/src/main/java/org/opensearch/common/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.opensearch.Version;
import org.opensearch.common.Booleans;
import org.opensearch.common.SetOnce;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.logging.LogConfigurator;
import org.opensearch.common.unit.MemorySizeValue;
Expand Down Expand Up @@ -96,9 +95,8 @@
/**
* An immutable settings implementation.
*
* @opensearch.api
* @opensearch.internal
*/
@PublicApi(since = "1.0.0")
public final class Settings implements ToXContentFragment {

public static final Settings EMPTY = new Builder().build();
Expand Down Expand Up @@ -270,21 +268,6 @@ public String get(String setting, String defaultValue) {
return retVal == null ? defaultValue : retVal;
}

/**
* Returns a setting value based on the setting key.
*/
public Settings getNestedSettings(String key) {
return (Settings) settings.get(key);
}

/**
* Returns a setting value based on the setting key.
*/
public List<Settings> getNestedListOfSettings(String key) {
return (List<Settings>) settings.get(key);
}


/**
* Returns the setting value (as float) associated with the setting key. If it does not exists,
* returns the default value provided.
Expand Down Expand Up @@ -681,7 +664,6 @@ private static void fromXContent(XContentParser parser, StringBuilder keyBuilder
fromXContent(parser, keyBuilder, builder, allowNullValues);
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
List<String> list = new ArrayList<>();
List<Object> listOfObjects = new ArrayList<>();
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
list.add(parser.text());
Expand All @@ -690,19 +672,12 @@ private static void fromXContent(XContentParser parser, StringBuilder keyBuilder
} else if (parser.currentToken() == XContentParser.Token.VALUE_BOOLEAN) {
list.add(String.valueOf(parser.text()));
} else {
listOfObjects.add(fromXContent(parser, true, false));
//throw new IllegalStateException("only value lists are allowed in serialized settings");
throw new IllegalStateException("only value lists are allowed in serialized settings");
}
}
String key = keyBuilder.toString();
validateValue(key, list, parser, allowNullValues);
builder.putList(key, list);
if (!listOfObjects.isEmpty()) {
builder.putListOfObjects(key, listOfObjects);
}
if (!list.isEmpty() && !listOfObjects.isEmpty()) {
throw new IllegalStateException("list cannot contain both values and objects");
}
} else if (parser.currentToken() == XContentParser.Token.VALUE_NULL) {
String key = keyBuilder.toString();
validateValue(key, null, parser, allowNullValues);
Expand Down Expand Up @@ -775,9 +750,8 @@ public Set<String> keySet() {
* settings implementation. Use {@link Settings#builder()} in order to
* construct it.
*
* @opensearch.api
* @opensearch.internal
*/
@PublicApi(since = "1.0.0")
public static class Builder {

public static final Settings EMPTY_SETTINGS = new Builder().build();
Expand Down Expand Up @@ -809,20 +783,6 @@ public String get(String key) {
return Settings.toString(map.get(key));
}

/**
* Returns a setting value based on the setting key.
*/
public Settings getNestedSettings(String key) {
return (Settings) map.get(key);
}

/**
* Returns a setting value based on the setting key.
*/
public List<Settings> getNestedListOfSettings(String key) {
return (List<Settings>) map.get(key);
}

/** Return the current secure settings, or {@code null} if none have been set. */
public SecureSettings getSecureSettings() {
return secureSettings.get();
Expand Down Expand Up @@ -1060,19 +1020,6 @@ public Builder putList(String setting, List<String> values) {
return this;
}

/**
* Sets the setting with the provided setting key and a list of values.
*
* @param setting The setting key
* @param values The values
* @return The builder
*/
public Builder putListOfObjects(String setting, List<Object> values) {
remove(setting);
map.put(setting, new ArrayList<>(values));
return this;
}

/**
* Sets all the provided settings including secure settings
*/
Expand Down

0 comments on commit 09f4339

Please sign in to comment.