Skip to content

Commit 7e772e3

Browse files
authored
Remove fromXContent from IndexUpgradeInfoResponse (#35934)
Such method is there only for testing purposes, it is not needed.
1 parent ad1f0dc commit 7e772e3

File tree

2 files changed

+1
-47
lines changed

2 files changed

+1
-47
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponse.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,18 @@
99
import org.elasticsearch.common.ParseField;
1010
import org.elasticsearch.common.io.stream.StreamInput;
1111
import org.elasticsearch.common.io.stream.StreamOutput;
12-
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
1312
import org.elasticsearch.common.xcontent.ToXContentObject;
1413
import org.elasticsearch.common.xcontent.XContentBuilder;
15-
import org.elasticsearch.common.xcontent.XContentParser;
1614

1715
import java.io.IOException;
1816
import java.util.Map;
1917
import java.util.Objects;
20-
import java.util.stream.Collectors;
21-
22-
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
2318

2419
public class IndexUpgradeInfoResponse extends ActionResponse implements ToXContentObject {
2520

2621
private static final ParseField INDICES = new ParseField("indices");
2722
private static final ParseField ACTION_REQUIRED = new ParseField("action_required");
2823

29-
private static final ConstructingObjectParser<IndexUpgradeInfoResponse, String> PARSER =
30-
new ConstructingObjectParser<>("IndexUpgradeInfoResponse",
31-
true,
32-
(a, c) -> {
33-
@SuppressWarnings("unchecked")
34-
Map<String, Object> map = (Map<String, Object>)a[0];
35-
Map<String, UpgradeActionRequired> actionsRequired = map.entrySet().stream()
36-
.filter(e -> {
37-
if (e.getValue() instanceof Map == false) {
38-
return false;
39-
}
40-
@SuppressWarnings("unchecked")
41-
Map<String, Object> value =(Map<String, Object>)e.getValue();
42-
return value.containsKey(ACTION_REQUIRED.getPreferredName());
43-
})
44-
.collect(Collectors.toMap(
45-
Map.Entry::getKey,
46-
e -> {
47-
@SuppressWarnings("unchecked")
48-
Map<String, Object> value = (Map<String, Object>) e.getValue();
49-
return UpgradeActionRequired.fromString((String)value.get(ACTION_REQUIRED.getPreferredName()));
50-
}
51-
));
52-
return new IndexUpgradeInfoResponse(actionsRequired);
53-
});
54-
55-
static {
56-
PARSER.declareObject(constructorArg(), (p, c) -> p.map(), INDICES);
57-
}
58-
59-
6024
private Map<String, UpgradeActionRequired> actions;
6125

6226
public IndexUpgradeInfoResponse() {
@@ -113,8 +77,4 @@ public boolean equals(Object o) {
11377
public int hashCode() {
11478
return Objects.hash(actions);
11579
}
116-
117-
public static IndexUpgradeInfoResponse fromXContent(XContentParser parser) {
118-
return PARSER.apply(parser, null);
119-
}
12080
}

x-pack/plugin/core/src/test/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponseTests.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.elasticsearch.common.xcontent.XContentParser;
99
import org.elasticsearch.protocol.AbstractHlrcStreamableXContentTestCase;
1010

11-
import java.io.IOException;
1211
import java.util.AbstractMap;
1312
import java.util.HashMap;
1413
import java.util.Iterator;
@@ -19,12 +18,7 @@ public class IndexUpgradeInfoResponseTests extends
1918
AbstractHlrcStreamableXContentTestCase<IndexUpgradeInfoResponse, org.elasticsearch.client.migration.IndexUpgradeInfoResponse> {
2019

2120
@Override
22-
protected IndexUpgradeInfoResponse doParseInstance(XContentParser parser) {
23-
return IndexUpgradeInfoResponse.fromXContent(parser);
24-
}
25-
26-
@Override
27-
public org.elasticsearch.client.migration.IndexUpgradeInfoResponse doHlrcParseInstance(XContentParser parser) throws IOException {
21+
public org.elasticsearch.client.migration.IndexUpgradeInfoResponse doHlrcParseInstance(XContentParser parser) {
2822
return org.elasticsearch.client.migration.IndexUpgradeInfoResponse.fromXContent(parser);
2923
}
3024

0 commit comments

Comments
 (0)