diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java index ce76583bb57fa..5ddd567d18a0c 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java @@ -59,7 +59,7 @@ public List getMlSettingsIssues() { private static List parseDeprecationIssues(XContentParser parser) throws IOException { List issues = new ArrayList<>(); - XContentParser.Token token = null; + XContentParser.Token token; while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.START_OBJECT) { issues.add(DeprecationIssue.PARSER.parse(parser, null)); @@ -116,8 +116,7 @@ public int hashCode() { @Override public String toString() { - return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString() + - ":" + mlSettingsIssues.toString(); + return clusterSettingsIssues + ":" + nodeSettingsIssues + ":" + indexSettingsIssues + ":" + mlSettingsIssues; } /** @@ -156,10 +155,10 @@ public String toString() { } } - private Level level; - private String message; - private String url; - private String details; + private final Level level; + private final String message; + private final String url; + private final String details; public DeprecationIssue(Level level, String message, String url, @Nullable String details) { this.level = level; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/DeprecationIssue.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/DeprecationIssue.java index 5daa29fe429b1..5b7e01c61fcf4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/DeprecationIssue.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/DeprecationIssue.java @@ -59,15 +59,10 @@ public String toString() { } } - private Level level; - private String message; - private String url; - private String details; - - // pkg-private for tests - DeprecationIssue() { - - } + private final Level level; + private final String message; + private final String url; + private final String details; public DeprecationIssue(Level level, String message, String url, @Nullable String details) { this.level = level; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckAction.java index e043e40b99127..49a6798d0add5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckAction.java @@ -52,7 +52,7 @@ public void writeTo(StreamOutput out) throws IOException { } public static class NodeResponse extends BaseNodeResponse { - private List deprecationIssues; + private final List deprecationIssues; public NodeResponse(StreamInput in) throws IOException { super(in); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationChecksTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationChecksTests.java index ab5bd42e5153d..c2ffb7dfd0c7e 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationChecksTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationChecksTests.java @@ -8,7 +8,6 @@ import org.elasticsearch.test.ESTestCase; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; @@ -17,7 +16,7 @@ public class DeprecationChecksTests extends ESTestCase { - public void testFilterChecks() throws IOException { + public void testFilterChecks() { DeprecationIssue issue = DeprecationIssueTests.createTestInstance(); int numChecksPassed = randomIntBetween(0, 5); int numChecksFailed = 10 - numChecksPassed; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationInfoActionResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationInfoActionResponseTests.java index 714f8e6153b84..ab16dcb058562 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationInfoActionResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationInfoActionResponseTests.java @@ -8,7 +8,6 @@ import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.Version; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -23,8 +22,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.indices.TestIndexNameExpressionResolver; import org.elasticsearch.test.AbstractWireSerializingTestCase; -import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig; -import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfigTests; import java.io.IOException; import java.util.Collections; @@ -85,10 +82,7 @@ public void testFrom() throws IOException { DiscoveryNode discoveryNode = DiscoveryNode.createLocal(Settings.EMPTY, new TransportAddress(TransportAddress.META_ADDRESS, 9300), "test"); ClusterState state = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).build(); - List datafeeds = Collections.singletonList(DatafeedConfigTests.createRandomizedDatafeedConfig("foo")); IndexNameExpressionResolver resolver = TestIndexNameExpressionResolver.newInstance(); - IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, - true, true); boolean clusterIssueFound = randomBoolean(); boolean nodeIssueFound = randomBoolean(); boolean indexIssueFound = randomBoolean(); diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java index fdf8cc3fb8079..56fb119519d4d 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java @@ -9,27 +9,16 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; import java.util.Locale; -import java.util.Map; -import java.util.function.BiConsumer; /** * Index-specific deprecation checks */ public class IndexDeprecationChecks { - private static void fieldLevelMappingIssue(IndexMetadata indexMetadata, BiConsumer> checker) { - MappingMetadata mmd = indexMetadata.mapping(); - if (mmd != null) { - Map sourceAsMap = mmd.sourceAsMap(); - checker.accept(mmd, sourceAsMap); - } - } - static DeprecationIssue oldIndicesCheck(IndexMetadata indexMetadata) { Version createdWith = indexMetadata.getCreationVersion(); if (createdWith.before(Version.V_7_0_0)) { diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index 24efa966b80f3..a6e84ac2b2b8b 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -15,93 +15,9 @@ import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; import java.util.Locale; -import java.util.function.BiFunction; public class NodeDeprecationChecks { - private static DeprecationIssue checkDeprecatedSetting( - final Settings settings, - final PluginsAndModules pluginsAndModules, - final Setting deprecatedSetting, - final Setting replacementSetting, - final String url - ) { - return checkDeprecatedSetting(settings, pluginsAndModules, deprecatedSetting, replacementSetting, (v, s) -> v, url); - } - - private static DeprecationIssue checkDeprecatedSetting( - final Settings settings, - final PluginsAndModules pluginsAndModules, - final Setting deprecatedSetting, - final Setting replacementSetting, - final BiFunction replacementValue, - final String url - ) { - assert deprecatedSetting.isDeprecated() : deprecatedSetting; - if (deprecatedSetting.exists(settings) == false) { - return null; - } - final String deprecatedSettingKey = deprecatedSetting.getKey(); - final String replacementSettingKey = replacementSetting.getKey(); - final String value = deprecatedSetting.get(settings).toString(); - final String message = String.format( - Locale.ROOT, - "setting [%s] is deprecated in favor of setting [%s]", - deprecatedSettingKey, - replacementSettingKey); - final String details = String.format( - Locale.ROOT, - "the setting [%s] is currently set to [%s], instead set [%s] to [%s]", - deprecatedSettingKey, - value, - replacementSettingKey, - replacementValue.apply(value, settings)); - return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details); - } - - private static DeprecationIssue checkDeprecatedSetting( - final Settings settings, - final PluginsAndModules pluginsAndModules, - final Setting deprecatedSetting, - final Setting.AffixSetting replacementSetting, - final String star, - final String url - ) { - return checkDeprecatedSetting(settings, pluginsAndModules, deprecatedSetting, replacementSetting, (v, s) -> v, star, url); - } - - private static DeprecationIssue checkDeprecatedSetting( - final Settings settings, - final PluginsAndModules pluginsAndModules, - final Setting deprecatedSetting, - final Setting.AffixSetting replacementSetting, - final BiFunction replacementValue, - final String star, - final String url - ) { - assert deprecatedSetting.isDeprecated() : deprecatedSetting; - if (deprecatedSetting.exists(settings) == false) { - return null; - } - final String deprecatedSettingKey = deprecatedSetting.getKey(); - final String replacementSettingKey = replacementSetting.getKey(); - final String value = deprecatedSetting.get(settings).toString(); - final String message = String.format( - Locale.ROOT, - "setting [%s] is deprecated in favor of grouped setting [%s]", - deprecatedSettingKey, - replacementSettingKey); - final String details = String.format( - Locale.ROOT, - "the setting [%s] is currently set to [%s], instead set [%s] to [%s] where * is %s", - deprecatedSettingKey, - value, - replacementSettingKey, - replacementValue.apply(value, settings), - star); - return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details); - } - static DeprecationIssue checkRemovedSetting(final Settings settings, final Setting removedSetting, final String url) { if (removedSetting.exists(settings) == false) { return null;