lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbern...@apache.org
Subject [2/2] lucene-solr:branch_6x: SOLR-9059: NPE in SolrClientCache following collection reload
Date Tue, 03 May 2016 17:21:18 GMT
SOLR-9059: NPE in SolrClientCache following collection reload

Conflicts:
	solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/0cb7d831
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0cb7d831
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0cb7d831

Branch: refs/heads/branch_6x
Commit: 0cb7d83193cb7e5c6cc3b2fb3b169402b0134aeb
Parents: 925f2b2
Author: jbernste <jbernste@apache.org>
Authored: Tue May 3 13:03:57 2016 -0400
Committer: jbernste <jbernste@apache.org>
Committed: Tue May 3 13:28:03 2016 -0400

----------------------------------------------------------------------
 .../org/apache/solr/handler/TestSQLHandler.java | 32 ++++++++++++++++++++
 .../solr/client/solrj/io/SolrClientCache.java   |  3 +-
 2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0cb7d831/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
index 9eca6db..bf111d6 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
@@ -30,6 +30,8 @@ import org.apache.solr.client.solrj.io.stream.ExceptionStream;
 import org.apache.solr.client.solrj.io.stream.SolrStream;
 import org.apache.solr.client.solrj.io.stream.TupleStream;
 import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.params.CommonParams;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -424,6 +426,36 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("myInt") == 7);
       assert(tuple.get("myString").equals("a"));
 
+      //Test after reload SOLR-9059//
+      Replica leader = getShardLeader("collection1", "shard1", 30 /* timeout secs */);
+
+      // reload collection and wait to see the core report it has been reloaded
+      boolean wasReloaded = reloadCollection(leader, "collection1");
+      assertTrue(wasReloaded);
+
+      params = new HashMap();
+      params.put(CommonParams.QT, "/sql");
+      params.put("stmt", "select id as myId, field_i as myInt, str_s as myString from collection1
where text='XXXX' AND id='(1 2 3)' order by field_i desc");
+
+      solrStream = new SolrStream(jetty.url, params);
+      tuples = getTuples(solrStream);
+
+      assert(tuples.size() == 3);
+
+      tuple = tuples.get(0);
+      assert(tuple.getLong("myId") == 3);
+      assert(tuple.getLong("myInt") == 20);
+      assert(tuple.get("myString").equals("a"));
+
+      tuple = tuples.get(1);
+      assert(tuple.getLong("myId") == 2);
+      assert(tuple.getLong("myInt") == 8);
+      assert(tuple.get("myString").equals("b"));
+
+      tuple = tuples.get(2);
+      assert(tuple.getLong("myId") == 1);
+      assert(tuple.getLong("myInt") == 7);
+      assert(tuple.get("myString").equals("a"));
 
     } finally {
       delete();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0cb7d831/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java
index cd992a4..da94162 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java
@@ -66,7 +66,7 @@ public class SolrClientCache implements Serializable {
     return client;
   }
 
-  public void close() {
+  public synchronized void close() {
     for(Map.Entry<String, SolrClient> entry : solrClients.entrySet()) {
       try {
         entry.getValue().close();
@@ -74,5 +74,6 @@ public class SolrClientCache implements Serializable {
         log.error("Error closing SolrClient for " + entry.getKey(), e);
       }
     }
+    solrClients.clear();
   }
 }


Mime
View raw message