Skip to content

Commit

Permalink
deprecation is not backwards compatible, removed from this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
stu-elastic committed Jan 22, 2024
1 parent 0094df2 commit bb03636
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -442,16 +441,12 @@ public boolean hasIndexScope() {
/**
* Returns <code>true</code> if this setting is deprecated, otherwise <code>false</code>
*/
protected boolean isDeprecated() {
private boolean isDeprecated() {
return properties.contains(Property.Deprecated)
|| properties.contains(Property.DeprecatedWarning)
|| properties.contains(Property.IndexSettingDeprecatedInV7AndRemovedInV8);
}

protected Stream<Tuple<String, String>> deprecatedKeyStream(Settings settings) {
return Stream.empty();
}

private boolean isDeprecatedWarningOnly() {
return properties.contains(Property.DeprecatedWarning);
}
Expand Down Expand Up @@ -654,16 +649,6 @@ void checkDeprecation(Settings settings) {
Settings.DeprecationLoggerHolder.deprecationLogger.critical(DeprecationCategory.SETTINGS, key, message, key);
}
}
String message = "[{}] setting was deprecated in Elasticsearch and will be removed in a future release, use [{}] instead";
deprecatedKeyStream(settings).forEach(deprecatedReplacement -> {
Settings.DeprecationLoggerHolder.deprecationLogger.warn(
DeprecationCategory.SETTINGS,
deprecatedReplacement.v1(),
message,
deprecatedReplacement.v1(),
deprecatedReplacement.v2()
);
});
}

/**
Expand Down Expand Up @@ -1095,17 +1080,6 @@ public Map<String, T> getAsMap(Settings settings) {
});
return Collections.unmodifiableMap(map);
}

@Override
protected Stream<Tuple<String, String>> deprecatedKeyStream(Settings settings) {
if (key.hasFallback() == false) {
return super.deprecatedKeyStream(settings);
}
return Stream.concat(
super.deprecatedKeyStream(settings),
settings.keySet().stream().map(key::maybeFallback).flatMap(Optional::stream)
);
}
}

/**
Expand Down Expand Up @@ -2250,19 +2224,6 @@ public boolean match(String key) {
return pattern.matcher(key).matches();
}

// package private for testing

/**
* If key is the fallback, return it and the primary key
*/
Optional<Tuple<String, String>> maybeFallback(String key) {
Matcher m = fallbackPattern.matcher(key);
if (m.matches() == false) {
return Optional.empty();
}
return Optional.of(new Tuple<>(key, m.replaceFirst(prefix + "$2")));
}

/**
* Does this key have a fallback prefix?
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -1437,29 +1436,6 @@ public void testCheckForDeprecation() {
assertSettingDeprecationsAndWarnings(new Setting<?>[] { deprecatedSettingWarningOnly });
}

public void testAffixSettingFallback() {
Setting.AffixKey key = new Setting.AffixKey("foo.bar.baz.", null, "qux.quux.");
Optional<Tuple<String, String>> replacement = key.maybeFallback("qux.quux.abc.123.doremi");
assertTrue(replacement.isPresent());
assertThat(replacement.get(), equalTo(new Tuple<>("qux.quux.abc.123.doremi", "foo.bar.baz.abc.123.doremi")));
assertFalse(key.maybeFallback("foo.bar.baz.123.doremi").isPresent());
}

public void testCheckForDeprecatedAffixSettings() {
Setting.AffixSetting<Boolean> setting = Setting.prefixKeySetting(
"foo.",
"bar.",
(ns, key) -> Setting.boolSetting(key, false, Property.NodeScope)
);
setting.checkDeprecation(Settings.builder().put("bar.a.1", true).put("bar.b.q.do", false).build());
assertWarnings(
"[bar.a.1] setting was deprecated in Elasticsearch and will be removed in a future release, use [foo.a.1] instead",
"[bar.b.q.do] setting was deprecated in Elasticsearch and will be removed in a future release, use [foo.b.q.do] instead"
);
setting.checkDeprecation(Settings.builder().put("foo.a.1", true).put("foo.b.q.d", false).build());
ensureNoWarnings();
}

public void testCheckForDeprecationWithSkipSetting() {
final String settingName = "foo.bar.hide.this";
final String settingValue = "blat";
Expand Down

0 comments on commit bb03636

Please sign in to comment.