From 384286d463d1d96c2017abfd6ed60fc98bce8888 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Thu, 11 Oct 2012 19:02:06 -0700 Subject: [PATCH] Mapping: Using _default_ mapping type with _source excludes (or array based config) can cause the array to grow indefinitely closes #2317 --- .../elasticsearch/common/xcontent/XContentHelper.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java b/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java index 136dde883bd..7244fc22ba8 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java @@ -32,7 +32,6 @@ import org.elasticsearch.common.io.stream.BytesStreamInput; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -241,8 +240,13 @@ public class XContentHelper { } } else { // if both are lists, simply combine them, first the defaults, then the content - mergedList.addAll((Collection) defaultEntry.getValue()); - mergedList.addAll((Collection) content.get(defaultEntry.getKey())); + // just make sure not to add the same value twice + mergedList.addAll(defaultList); + for (Object o : contentList) { + if (!mergedList.contains(o)) { + mergedList.add(o); + } + } } content.put(defaultEntry.getKey(), mergedList); }