You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/03/01 09:27:33 UTC
[25/50] [abbrv] lucene-solr:jira/solr-9858: SOLR-10190: Fix NPE in
CloudSolrClient when reading stale alias
SOLR-10190: Fix NPE in CloudSolrClient when reading stale alias
This closes #160
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/39887b86
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/39887b86
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/39887b86
Branch: refs/heads/jira/solr-9858
Commit: 39887b86297e36785607f57cfd0e785bcae3c61a
Parents: 30125f9
Author: Tomas Fernandez Lobbe <tf...@apache.org>
Authored: Fri Feb 24 17:33:12 2017 -0800
Committer: Tomas Fernandez Lobbe <tf...@apache.org>
Committed: Fri Feb 24 17:33:12 2017 -0800
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../solr/client/solrj/impl/CloudSolrClient.java | 3 +++
.../client/solrj/impl/CloudSolrClientTest.java | 25 ++++++++++++++++++++
3 files changed, 30 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/39887b86/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0302615..2b0044c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -275,6 +275,8 @@ Bug Fixes
* SOLR-10083: Fix instanceof check in ConstDoubleSource.equals (Pushkar Raste via Christine Poerschke)
+* SOLR-10190: Fix NPE in CloudSolrClient when reading stale alias (Janosch Woschitz via Tom�s Fern�ndez L�bbe)
+
================== 6.4.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/39887b86/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index d0263c8..3147d4e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -1075,6 +1075,9 @@ public class CloudSolrClient extends SolrClient {
for (String requestedCollection : requestedCollectionNames) {
// track the version of state we're using on the client side using the _stateVer_ param
DocCollection coll = getDocCollection(requestedCollection, null);
+ if (coll == null) {
+ throw new SolrException(ErrorCode.BAD_REQUEST, "Collection not found: " + requestedCollection);
+ }
int collVer = coll.getZNodeVersion();
if (coll.getStateFormat()>1) {
if(requestedCollections == null) requestedCollections = new ArrayList<>(requestedCollectionNames.size());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/39887b86/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
index 1698075..cff5c23 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
@@ -147,6 +147,31 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
}
@Test
+ public void testHandlingOfStaleAlias() throws Exception {
+ try (CloudSolrClient client = getCloudSolrClient(cluster.getZkServer().getZkAddress())) {
+ client.setDefaultCollection("misconfigured-alias");
+
+ CollectionAdminRequest.createCollection("nemesis", "conf", 2, 1).process(client);
+ CollectionAdminRequest.createAlias("misconfigured-alias", "nemesis").process(client);
+ CollectionAdminRequest.deleteCollection("nemesis").process(client);
+
+ List<SolrInputDocument> docs = new ArrayList<>();
+
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField(id, Integer.toString(1));
+ docs.add(doc);
+
+ try {
+ client.add(docs);
+ fail("Alias points to non-existing collection, add should fail");
+ } catch (SolrException e) {
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ assertTrue("Unexpected error exception", e.getMessage().contains("Collection not found"));
+ }
+ }
+ }
+
+ @Test
public void testRouting() throws Exception {
AbstractUpdateRequest request = new UpdateRequest()