mirror of https://github.com/apache/lucene.git
SOLR-10190: Fix NPE in CloudSolrClient when reading stale alias
This closes #160
This commit is contained in:
parent
30125f99da
commit
39887b8629
|
@ -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.
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -146,6 +146,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 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue