Skip to content

Commit 92634cb

Browse files
authored
Tidy up deprecation code. (#74095)
Backporting #74065 to 7.x branch. Removed unused code and made fields immutable.
1 parent 92f7c62 commit 92634cb

File tree

5 files changed

+12
-25
lines changed

5 files changed

+12
-25
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public List<DeprecationIssue> getMlSettingsIssues() {
5959

6060
private static List<DeprecationIssue> parseDeprecationIssues(XContentParser parser) throws IOException {
6161
List<DeprecationIssue> issues = new ArrayList<>();
62-
XContentParser.Token token = null;
62+
XContentParser.Token token;
6363
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
6464
if (token == XContentParser.Token.START_OBJECT) {
6565
issues.add(DeprecationIssue.PARSER.parse(parser, null));
@@ -116,8 +116,7 @@ public int hashCode() {
116116

117117
@Override
118118
public String toString() {
119-
return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString() +
120-
":" + mlSettingsIssues.toString();
119+
return clusterSettingsIssues + ":" + nodeSettingsIssues + ":" + indexSettingsIssues + ":" + mlSettingsIssues;
121120
}
122121

123122
/**
@@ -156,10 +155,10 @@ public String toString() {
156155
}
157156
}
158157

159-
private Level level;
160-
private String message;
161-
private String url;
162-
private String details;
158+
private final Level level;
159+
private final String message;
160+
private final String url;
161+
private final String details;
163162

164163
public DeprecationIssue(Level level, String message, String url, @Nullable String details) {
165164
this.level = level;

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/DeprecationIssue.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,10 @@ public String toString() {
5959
}
6060
}
6161

62-
private Level level;
63-
private String message;
64-
private String url;
65-
private String details;
66-
67-
// pkg-private for tests
68-
DeprecationIssue() {
69-
70-
}
62+
private final Level level;
63+
private final String message;
64+
private final String url;
65+
private final String details;
7166

7267
public DeprecationIssue(Level level, String message, String url, @Nullable String details) {
7368
this.level = level;

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/deprecation/NodesDeprecationCheckAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void writeTo(StreamOutput out) throws IOException {
5252
}
5353

5454
public static class NodeResponse extends BaseNodeResponse {
55-
private List<DeprecationIssue> deprecationIssues;
55+
private final List<DeprecationIssue> deprecationIssues;
5656

5757
public NodeResponse(StreamInput in) throws IOException {
5858
super(in);

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationChecksTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import org.elasticsearch.test.ESTestCase;
1010

11-
import java.io.IOException;
1211
import java.util.ArrayList;
1312
import java.util.List;
1413
import java.util.function.Supplier;
@@ -17,7 +16,7 @@
1716

1817
public class DeprecationChecksTests extends ESTestCase {
1918

20-
public void testFilterChecks() throws IOException {
19+
public void testFilterChecks() {
2120
DeprecationIssue issue = DeprecationIssueTests.createTestInstance();
2221
int numChecksPassed = randomIntBetween(0, 5);
2322
int numChecksFailed = 10 - numChecksPassed;

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/deprecation/DeprecationInfoActionResponseTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import org.elasticsearch.ElasticsearchStatusException;
1010
import org.elasticsearch.Version;
11-
import org.elasticsearch.action.support.IndicesOptions;
1211
import org.elasticsearch.cluster.ClusterName;
1312
import org.elasticsearch.cluster.ClusterState;
1413
import org.elasticsearch.cluster.metadata.IndexMetadata;
@@ -23,8 +22,6 @@
2322
import org.elasticsearch.common.xcontent.XContentFactory;
2423
import org.elasticsearch.indices.TestIndexNameExpressionResolver;
2524
import org.elasticsearch.test.AbstractWireSerializingTestCase;
26-
import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig;
27-
import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfigTests;
2825

2926
import java.io.IOException;
3027
import java.util.Arrays;
@@ -86,10 +83,7 @@ public void testFrom() throws IOException {
8683
DiscoveryNode discoveryNode = DiscoveryNode.createLocal(Settings.EMPTY,
8784
new TransportAddress(TransportAddress.META_ADDRESS, 9300), "test");
8885
ClusterState state = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).build();
89-
List<DatafeedConfig> datafeeds = Collections.singletonList(DatafeedConfigTests.createRandomizedDatafeedConfig("foo"));
9086
IndexNameExpressionResolver resolver = TestIndexNameExpressionResolver.newInstance();
91-
IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false,
92-
true, true);
9387
boolean clusterIssueFound = randomBoolean();
9488
boolean nodeIssueFound = randomBoolean();
9589
boolean indexIssueFound = randomBoolean();

0 commit comments

Comments
 (0)