From b3241a23b34ebfa633766e6a6a31e831ba653fd2 Mon Sep 17 00:00:00 2001 From: Tommaso Teofili Date: Tue, 24 Apr 2012 11:18:59 +0000 Subject: [PATCH] [SOLR-3396] - avoid NPEs on appendMap method git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1329640 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/client/solrj/util/ClientUtils.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java b/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java index b7b0b5eddd9..6353e8332a2 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java @@ -23,13 +23,7 @@ import java.io.Writer; import java.net.URLEncoder; import java.text.DateFormat; import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.TimeZone; +import java.util.*; import java.util.Map.Entry; import java.nio.ByteBuffer; @@ -231,9 +225,13 @@ public class ClientUtils } public static void appendMap(String collection, Map map1, Map map2) { - Set> entrySet = map2.entrySet(); - for (Entry entry : entrySet) { - map1.put(collection + "_" + entry.getKey(), entry.getValue()); + if (map1==null) + map1 = new HashMap(); + if (map2!=null) { + Set> entrySet = map2.entrySet(); + for (Entry entry : entrySet) { + map1.put(collection + "_" + entry.getKey(), entry.getValue()); + } } } }