[HLRC] Ignore unknown fields in responses of CCR APIs (#36821)

Otherwise hlrc fails if new fields are introduced in ccr api responses
in future versions.
This commit is contained in:
Martijn van Groningen 2019-01-10 14:04:55 +01:00 committed by GitHub
parent 61b54196c4
commit 44acb016a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 23 additions and 12 deletions

View File

@ -47,7 +47,9 @@ public final class AutoFollowStats {
static final ParseField LAST_SEEN_METADATA_VERSION = new ParseField("last_seen_metadata_version");
@SuppressWarnings("unchecked")
static final ConstructingObjectParser<AutoFollowStats, Void> STATS_PARSER = new ConstructingObjectParser<>("auto_follow_stats",
static final ConstructingObjectParser<AutoFollowStats, Void> STATS_PARSER = new ConstructingObjectParser<>(
"auto_follow_stats",
true,
args -> new AutoFollowStats(
(Long) args[0],
(Long) args[1],
@ -65,11 +67,13 @@ public final class AutoFollowStats {
static final ConstructingObjectParser<Map.Entry<String, Tuple<Long, ElasticsearchException>>, Void> AUTO_FOLLOW_EXCEPTIONS_PARSER =
new ConstructingObjectParser<>(
"auto_follow_stats_errors",
true,
args -> new AbstractMap.SimpleEntry<>((String) args[0], Tuple.tuple((Long) args[1], (ElasticsearchException) args[2])));
private static final ConstructingObjectParser<Map.Entry<String, AutoFollowedCluster>, Void> AUTO_FOLLOWED_CLUSTERS_PARSER =
new ConstructingObjectParser<>(
"auto_followed_clusters",
true,
args -> new AbstractMap.SimpleEntry<>((String) args[0], new AutoFollowedCluster((Long) args[1], (Long) args[2])));
static {

View File

@ -28,7 +28,9 @@ public final class CcrStatsResponse {
static final ParseField AUTO_FOLLOW_STATS_FIELD = new ParseField("auto_follow_stats");
static final ParseField FOLLOW_STATS_FIELD = new ParseField("follow_stats");
private static final ConstructingObjectParser<CcrStatsResponse, Void> PARSER = new ConstructingObjectParser<>("indices",
private static final ConstructingObjectParser<CcrStatsResponse, Void> PARSER = new ConstructingObjectParser<>(
"indices",
true,
args -> {
AutoFollowStats autoFollowStats = (AutoFollowStats) args[0];
IndicesFollowStats indicesFollowStats = (IndicesFollowStats) args[1];

View File

@ -42,7 +42,7 @@ public final class GetAutoFollowPatternResponse {
static final ParseField PATTERN_FIELD = new ParseField("pattern");
private static final ConstructingObjectParser<Map.Entry<String, Pattern>, Void> ENTRY_PARSER = new ConstructingObjectParser<>(
"get_auto_follow_pattern_response", args -> new AbstractMap.SimpleEntry<>((String) args[0], (Pattern) args[1]));
"get_auto_follow_pattern_response", true, args -> new AbstractMap.SimpleEntry<>((String) args[0], (Pattern) args[1]));
static {
ENTRY_PARSER.declareString(ConstructingObjectParser.constructorArg(), NAME_FIELD);
@ -50,7 +50,7 @@ public final class GetAutoFollowPatternResponse {
}
private static final ConstructingObjectParser<GetAutoFollowPatternResponse, Void> PARSER = new ConstructingObjectParser<>(
"get_auto_follow_pattern_response", args -> {
"get_auto_follow_pattern_response", true, args -> {
@SuppressWarnings("unchecked")
List<Map.Entry<String, Pattern>> entries = (List<Map.Entry<String, Pattern>>) args[0];
return new GetAutoFollowPatternResponse(new TreeMap<>(entries.stream()
@ -92,7 +92,7 @@ public final class GetAutoFollowPatternResponse {
@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<Pattern, Void> PARSER = new ConstructingObjectParser<>(
"pattern", args -> new Pattern((String) args[0], (List<String>) args[1], (String) args[2]));
"pattern", true, args -> new Pattern((String) args[0], (List<String>) args[1], (String) args[2]));
static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), PutFollowRequest.REMOTE_CLUSTER_FIELD);

View File

@ -41,6 +41,7 @@ public final class IndicesFollowStats {
private static final ConstructingObjectParser<Tuple<String, List<ShardFollowStats>>, Void> ENTRY_PARSER =
new ConstructingObjectParser<>(
"entry",
true,
args -> {
String index = (String) args[0];
@SuppressWarnings("unchecked")
@ -54,7 +55,9 @@ public final class IndicesFollowStats {
ENTRY_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), ShardFollowStats.PARSER, SHARDS_FIELD);
}
static final ConstructingObjectParser<IndicesFollowStats, Void> PARSER = new ConstructingObjectParser<>("indices",
static final ConstructingObjectParser<IndicesFollowStats, Void> PARSER = new ConstructingObjectParser<>(
"indices",
true,
args -> {
@SuppressWarnings("unchecked")
List<Tuple<String, List<ShardFollowStats>>> entries = (List<Tuple<String, List<ShardFollowStats>>>) args[0];
@ -116,6 +119,7 @@ public final class IndicesFollowStats {
static final ConstructingObjectParser<ShardFollowStats, Void> PARSER =
new ConstructingObjectParser<>(
"shard-follow-stats",
true,
args -> new ShardFollowStats(
(String) args[0],
(String) args[1],
@ -152,6 +156,7 @@ public final class IndicesFollowStats {
static final ConstructingObjectParser<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>, Void> READ_EXCEPTIONS_ENTRY_PARSER =
new ConstructingObjectParser<>(
"shard-follow-stats-read-exceptions-entry",
true,
args -> new AbstractMap.SimpleEntry<>((long) args[0], Tuple.tuple((Integer) args[1], (ElasticsearchException)args[2])));
static {

View File

@ -33,7 +33,7 @@ public final class PutFollowResponse {
static final ParseField INDEX_FOLLOWING_STARTED = new ParseField("index_following_started");
private static final ConstructingObjectParser<PutFollowResponse, Void> PARSER = new ConstructingObjectParser<>(
"put_follow_response", args -> new PutFollowResponse((boolean) args[0], (boolean) args[1], (boolean) args[2]));
"put_follow_response", true, args -> new PutFollowResponse((boolean) args[0], (boolean) args[1], (boolean) args[2]));
static {
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), FOLLOW_INDEX_CREATED);

View File

@ -51,7 +51,7 @@ public class CcrStatsResponseTests extends ESTestCase {
CcrStatsResponseTests::createTestInstance,
CcrStatsResponseTests::toXContent,
CcrStatsResponse::fromXContent)
.supportsUnknownFields(false)
.supportsUnknownFields(true)
.assertEqualsConsumer(CcrStatsResponseTests::assertEqualInstances)
.assertToXContentEquivalence(false)
.test();

View File

@ -48,7 +48,7 @@ public class FollowStatsResponseTests extends ESTestCase {
FollowStatsResponseTests::createTestInstance,
FollowStatsResponseTests::toXContent,
FollowStatsResponse::fromXContent)
.supportsUnknownFields(false)
.supportsUnknownFields(true)
.assertEqualsConsumer(FollowStatsResponseTests::assertEqualInstances)
.assertToXContentEquivalence(false)
.test();

View File

@ -43,7 +43,7 @@ public class GetAutoFollowPatternResponseTests extends ESTestCase {
this::createTestInstance,
GetAutoFollowPatternResponseTests::toXContent,
GetAutoFollowPatternResponse::fromXContent)
.supportsUnknownFields(false)
.supportsUnknownFields(true)
.test();
}

View File

@ -31,7 +31,7 @@ import java.io.IOException;
public class PutFollowRequestTests extends AbstractXContentTestCase<PutFollowRequest> {
private static final ConstructingObjectParser<PutFollowRequest, Void> PARSER = new ConstructingObjectParser<>("test_parser",
(args) -> new PutFollowRequest((String) args[0], (String) args[1], (String) args[2]));
true, (args) -> new PutFollowRequest((String) args[0], (String) args[1], (String) args[2]));
static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), PutFollowRequest.REMOTE_CLUSTER_FIELD);

View File

@ -33,7 +33,7 @@ public class PutFollowResponseTests extends ESTestCase {
this::createTestInstance,
PutFollowResponseTests::toXContent,
PutFollowResponse::fromXContent)
.supportsUnknownFields(false)
.supportsUnknownFields(true)
.test();
}