gnodet-bot commented on code in PR #28051:
URL: https://github.com/apache/camel/pull/28051#discussion_r4306871706


##########
components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientProducer.java:
##########
@@ -375,15 +377,17 @@ String extractSearch(JsonObject doc) {
      * Creates Rest Client from information in the Endpoint
      */
     private RestClient createClient() throws Exception {
-        final RestClientBuilder builder = RestClient.builder(getHttpHosts());
+        final HttpHost[] httpHosts = getHttpHosts();
+        final RestClientBuilder builder = RestClient.builder(httpHosts);
+        // the credentials provider reads the nodes from the client, as the 
sniffer can change them
+        final AtomicReference<RestClient> restClientRef = new 
AtomicReference<>();
 
         builder.setRequestConfigCallback(requestConfigBuilder -> 
requestConfigBuilder
                 
.setConnectTimeout(this.endpoint.getConnectionTimeout()).setSocketTimeout(this.endpoint.getSocketTimeout()));
 
-        if (this.endpoint.getUser() != null && this.endpoint.getPassword() != 
null) {
-            final CredentialsProvider credentialsProvider = new 
BasicCredentialsProvider();
-            credentialsProvider.setCredentials(AuthScope.ANY,
-                    new UsernamePasswordCredentials(this.endpoint.getUser(), 
this.endpoint.getPassword()));
+        final CredentialsProvider credentialsProvider

Review Comment:
   ℹ️ **Note (pre-existing, not introduced by this PR):** The `certificatePath` 
SSL setup is inside the `if (credentialsProvider != null)` block, which means 
SSL is not configured when no user/password credentials are set. This was the 
same structure on the base branch before this change — the PR correctly 
preserves it.
   
   The `camel-opensearch` component handled this differently on this branch 
(SSL was independent of credentials in `setHttpClientConfigCallback`), so 
there's an inconsistency across the three components that predates this PR. 
Worth a separate fix if SSL-without-credentials is a desired use case.



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

Reply via email to