diff --git a/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java b/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java index a4ed0597062..53807545084 100644 --- a/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java +++ b/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java @@ -381,7 +381,7 @@ public class XMLLoader extends ContentStreamLoader { float boost = 1.0f; boolean isNull = false; String update = null; - Map>> updateMap = null; + Map> updateMap = null; boolean complete = false; while (!complete) { int event = parser.next(); @@ -400,18 +400,27 @@ public class XMLLoader extends ContentStreamLoader { } else if ("field".equals(parser.getLocalName())) { Object v = isNull ? null : text.toString(); if (update != null) { - if (updateMap == null) updateMap = new HashMap>>(); - Map> extendedValues = updateMap.get(name); + if (updateMap == null) updateMap = new HashMap>(); + Map extendedValues = updateMap.get(name); if (extendedValues == null) { - extendedValues = new HashMap>(1); + extendedValues = new HashMap(1); updateMap.put(name, extendedValues); } - List values = extendedValues.get(update); - if (values == null) { - values = new ArrayList(); - extendedValues.put(update, values); + Object val = extendedValues.get(update); + if (val == null) { + extendedValues.put(update, v); + } else { + // multiple val are present + if (val instanceof List) { + List list = (List) val; + list.add(v); + } else { + List values = new ArrayList(); + values.add(val); + values.add(v); + extendedValues.put(update, values); + } } - values.add(v); break; } doc.addField(name, v, boost); @@ -450,9 +459,9 @@ public class XMLLoader extends ContentStreamLoader { } if (updateMap != null) { - for (Map.Entry>> entry : updateMap.entrySet()) { + for (Map.Entry> entry : updateMap.entrySet()) { name = entry.getKey(); - Map> value = entry.getValue(); + Map value = entry.getValue(); doc.addField(name, value, 1.0f); } } diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java index 09b2c47a8d1..ff0819f5e99 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java @@ -118,7 +118,7 @@ public class ShardRoutingTest extends AbstractFullDistribZkTestBase { doHashingTest(); doTestNumRequests(); - // doAtomicUpdate(); TODO: this currently fails! + doAtomicUpdate(); testFinished = true; } finally {