laminelam opened a new pull request, #2412:
URL: https://github.com/apache/solr/pull/2412

   
   https://issues.apache.org/jira/browse/SOLR-17194
   
   
   Possible duplicate of  [2378](https://github.com/apache/solr/pull/2378) 
   
   # Description
   
    
   
   When creating a _CloudHttp2SolrClient_ with solrUrls and using an 
_internalClientBuilder_, the statement 
   
   `stateProvider = new Http2ClusterStateProvider(solrUrls, httpClient);`
             
   is called 
[BEFORE](https://github.com/apache/solr/blob/c3c83ffb8dba17dd79f78429df65869d1b7d87bb/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java#L424)
 the effective _httpClient_ is set 
[inside](https://github.com/apache/solr/blob/c3c83ffb8dba17dd79f78429df65869d1b7d87bb/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java#L66)
 CloudHttp2SolrClient constructor. So the _stateProvider_ will end up using the 
default _httpClient_ which doesn't have the extra settings of the one passed 
via the internal builder. For example, The  _Authorization header_ will be 
missing, which leads to 401 when trying to get the cluster state from cluster 
nodes.
   
   The reason is because when we  build with 
[withInternalClientBuilder](https://github.com/apache/solr/blob/c3c83ffb8dba17dd79f78429df65869d1b7d87bb/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java#L377),
 httpClient is null. If httpClient is null  _Http2ClusterStateProvider_ [will 
create](https://github.com/apache/solr/blob/c3c83ffb8dba17dd79f78429df65869d1b7d87bb/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java#L30)
 a default "empty" one.
   
   
   # Solution
   
   Pushed most of the code into the CloudHttp2SolrClient constructor. The idea 
is to first assign/build the myClient and then pass it to 
Http2ClusterStateProvider. This guaranties that one and unique httClient 
instance is used (and released).
   
   This PR assumes that _stateProvider_ is always null when [calling the 
build() 
method](https://github.com/apache/solr/blob/c3c83ffb8dba17dd79f78429df65869d1b7d87bb/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java#L410),
 so no need to test for _stateProvider==null_. The method allowing setting a 
_stateProvider_ externally is removed and only available in the deprecated 
_CloudLegacySolrClient_ class.
   
   # Tests
   
   Added a test case to test if the same _httpClient_ is preserved in both 
CloudHttp2SolrClient and Http2ClusterStateProvider.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to 
Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my 
code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request 
title.
   - [x] I have given Solr maintainers 
[access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
 to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [x] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference 
Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to