bruno-roustant commented on a change in pull request #2472:
URL: https://github.com/apache/lucene-solr/pull/2472#discussion_r603922188



##########
File path: solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
##########
@@ -271,7 +274,36 @@ public IndexFetcher(@SuppressWarnings({"rawtypes"})final 
NamedList initArgs, fin
     String httpBasicAuthPassword = (String) 
initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_PASS);
     myHttpClient = createHttpClient(solrCore, httpBasicAuthUser, 
httpBasicAuthPassword, useExternalCompression);
   }
-  
+
+  private void setLeaderUrl(String leaderUrl) {
+    if (leaderUrl != null) {
+      ShardHandlerFactory shardHandlerFactory = 
solrCore.getCoreContainer().getShardHandlerFactory();
+      if (shardHandlerFactory instanceof HttpShardHandlerFactory) {
+        ZkController zkController = 
solrCore.getCoreContainer().getZkController();
+        ClusterState clusterState = zkController == null ? null : 
zkController.getClusterState();
+        try {
+          ((HttpShardHandlerFactory) 
shardHandlerFactory).getWhitelistHostChecker()
+              .checkWhitelist(clusterState, null, 
Collections.singletonList(leaderUrl));
+        } catch (SolrException e) {
+          // Replace the exception because the message is about the 'shard' 
parameter, which is not right here.
+          // This code is refactored and cleaned up in 9.x and above.
+          if (e.code() == ErrorCode.BAD_REQUEST.code) {
+            throw new SolrException(ErrorCode.BAD_REQUEST,
+                "Invalid URL syntax in '" + LEADER_URL + "' with value '" + 
leaderUrl + "'", e);
+          } else {
+            log.warn("The '{}' parameter value '{}' is not in the '{}'",
+                LEADER_URL, leaderUrl, 
HttpShardHandlerFactory.INIT_SHARDS_WHITELIST);
+            throw new SolrException(SolrException.ErrorCode.FORBIDDEN,
+                "The '" + LEADER_URL + "' parameter value '" + leaderUrl
+                    + "' is not in the '" + 
HttpShardHandlerFactory.INIT_SHARDS_WHITELIST + "'."
+                    + 
HttpShardHandlerFactory.SET_SOLR_DISABLE_SHARDS_WHITELIST_CLUE);

Review comment:
       This suggestion exists in 3 other places: HttpShardHandler, 
HttpShardHandlerFactory, TermsComponent.
   I propose we keep it for this minimal patch for branch 8x and we can add a 
link to the doc in the change for main 9x?




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

Reply via email to