Bläddra i källkod

Fix BWC assertion in GetFieldMappingsResponse (#49706)

Closes #49702
Alan Woodward 5 år sedan
förälder
incheckning
770a794807

+ 6 - 1
server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java

@@ -36,6 +36,7 @@ import org.elasticsearch.index.mapper.MapperService;
 
 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();