dsmiley commented on code in PR #4260:
URL: https://github.com/apache/solr/pull/4260#discussion_r3049371483


##########
solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientConnectionTest.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.impl;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import org.apache.solr.SolrTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CloudSolrClientConnectionTest extends SolrTestCase {

Review Comment:
   See 
[SolrTestCaseJ4](https://github.com/apache/solr/blob/0989327c6bdb4973c1e20f2fd8a8c1b5d6b18542/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java#L336)
 DDEAD_HOST_1 etc.



##########
solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java:
##########
@@ -77,29 +77,37 @@ public void setDefaultZKHost(String zkHost) {
     }
   }
 
-  public synchronized CloudSolrClient getCloudSolrClient(String zkHost) {
+  public synchronized CloudSolrClient getCloudSolrClient(String 
connectionString) {
     ensureOpen();
-    Objects.requireNonNull(zkHost, "ZooKeeper host cannot be null!");
-    if (solrClients.containsKey(zkHost)) {
-      return (CloudSolrClient) solrClients.get(zkHost);
+    Objects.requireNonNull(connectionString, "Connection string cannot be 
null!");
+    if (solrClients.containsKey(connectionString)) {
+      return (CloudSolrClient) solrClients.get(connectionString);
     }
     // Can only use ZK ACLs if there is a default ZK Host, and the given ZK 
host contains that
     // default.
     // Basically the ZK ACLs are assumed to be only used for the default ZK 
host,
     // thus we should only provide the ACLs to that Zookeeper instance.
-    String zkHostNoChroot = zkHost.split("/")[0];
-    boolean canUseACLs =
-        
Optional.ofNullable(defaultZkHost.get()).map(zkHostNoChroot::equals).orElse(false);
+    boolean canUseACLs = false;
+    CloudSolrClient.CloudSolrClientConnection cloudClientConnection =

Review Comment:
   Surely `var` makes sense here, if the case for var cold be made anywhere -- 
this is the poster-child.



##########
solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java:
##########
@@ -77,29 +77,37 @@ public void setDefaultZKHost(String zkHost) {
     }
   }
 
-  public synchronized CloudSolrClient getCloudSolrClient(String zkHost) {
+  public synchronized CloudSolrClient getCloudSolrClient(String 
connectionString) {
     ensureOpen();
-    Objects.requireNonNull(zkHost, "ZooKeeper host cannot be null!");
-    if (solrClients.containsKey(zkHost)) {
-      return (CloudSolrClient) solrClients.get(zkHost);
+    Objects.requireNonNull(connectionString, "Connection string cannot be 
null!");
+    if (solrClients.containsKey(connectionString)) {
+      return (CloudSolrClient) solrClients.get(connectionString);
     }
     // Can only use ZK ACLs if there is a default ZK Host, and the given ZK 
host contains that
     // default.
     // Basically the ZK ACLs are assumed to be only used for the default ZK 
host,
     // thus we should only provide the ACLs to that Zookeeper instance.
-    String zkHostNoChroot = zkHost.split("/")[0];
-    boolean canUseACLs =
-        
Optional.ofNullable(defaultZkHost.get()).map(zkHostNoChroot::equals).orElse(false);
+    boolean canUseACLs = false;
+    CloudSolrClient.CloudSolrClientConnection cloudClientConnection =
+        CloudSolrClient.CloudSolrClientConnection.parse(connectionString);
+    if (cloudClientConnection.isZk()) {
+      String chroot = cloudClientConnection.zkChroot();
+      String zkHostNoChroot =
+          StrUtils.isNotBlank(chroot) && connectionString.endsWith(chroot)

Review Comment:
   the parser ought to ensure that there's no blank chroot.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to