lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1329640 - /lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
Date Tue, 24 Apr 2012 11:18:59 GMT
Author: tommaso
Date: Tue Apr 24 11:18:59 2012
New Revision: 1329640

URL: http://svn.apache.org/viewvc?rev=1329640&view=rev
Log:
[SOLR-3396] - avoid NPEs on appendMap method

Modified:
    lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java?rev=1329640&r1=1329639&r2=1329640&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
(original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
Tue Apr 24 11:18:59 2012
@@ -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<String,Slice> map1, Map<String,Slice>
map2) {
-    Set<Entry<String,Slice>> entrySet = map2.entrySet();
-    for (Entry<String,Slice> entry : entrySet) {
-      map1.put(collection + "_" + entry.getKey(), entry.getValue());
+    if (map1==null)
+      map1 = new HashMap<String,Slice>();
+    if (map2!=null) {
+      Set<Entry<String,Slice>> entrySet = map2.entrySet();
+      for (Entry<String,Slice> entry : entrySet) {
+        map1.put(collection + "_" + entry.getKey(), entry.getValue());
+      }
     }
   }
 }



Mime
View raw message