From b7bac252ba10d2747ed775cc7b2e5008026b3859 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Fri, 29 Nov 2019 10:32:57 +0000 Subject: [PATCH] Fix BWC assertion in GetFieldMappingsResponse (#49706) Closes #49702 --- .../indices/mapping/get/GetFieldMappingsResponse.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java index bd4fbc5f82af5..c57ebbb942f68 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java @@ -36,6 +36,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -66,7 +67,11 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte String index = in.readString(); if (in.getVersion().before(Version.V_8_0_0)) { int typesSize = in.readVInt(); - assert typesSize == 1; + assert typesSize == 1 || typesSize == 0 : "Expected 0 or 1 types but got " + typesSize; + if (typesSize == 0) { + indexMapBuilder.put(index, Collections.emptyMap()); + continue; + } in.readString(); // type } int fieldSize = in.readVInt();