murblanc commented on a change in pull request #2179: URL: https://github.com/apache/lucene-solr/pull/2179#discussion_r552198751
########## File path: solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java ########## @@ -116,6 +121,25 @@ public void call(ClusterState clusterState, ZkNodeProps message, @SuppressWarnin throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "collection alias already exists: " + collectionName); } + String withCollection = message.getStr(WITH_COLLECTION); + String withCollectionShard = null; + if (withCollection != null) { + String realWithCollection = aliases.resolveSimpleAlias(withCollection); + if (!clusterState.hasCollection(realWithCollection)) { + throw new SolrException(ErrorCode.BAD_REQUEST, "The 'withCollection' does not exist: " + realWithCollection); + } else { + DocCollection collection = clusterState.getCollection(realWithCollection); + if (collection.getActiveSlices().size() > 1) { Review comment: Maybe test !=1 to make sure it really has at least one? Friendlier to fail with the `SolrException` here than below with `next()` throwing `NoSuchElementException`. ########## File path: solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java ########## @@ -116,6 +121,25 @@ public void call(ClusterState clusterState, ZkNodeProps message, @SuppressWarnin throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "collection alias already exists: " + collectionName); } + String withCollection = message.getStr(WITH_COLLECTION); + String withCollectionShard = null; + if (withCollection != null) { + String realWithCollection = aliases.resolveSimpleAlias(withCollection); + if (!clusterState.hasCollection(realWithCollection)) { + throw new SolrException(ErrorCode.BAD_REQUEST, "The 'withCollection' does not exist: " + realWithCollection); + } else { + DocCollection collection = clusterState.getCollection(realWithCollection); + if (collection.getActiveSlices().size() > 1) { Review comment: Maybe test `!=1` to make sure it really has at least one? Friendlier to fail with the `SolrException` here than below with `next()` throwing `NoSuchElementException`. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org