This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 54b578218776 CAMEL-24815: camel-opensearch - honour socketTimeout 
without SSL and scope basic auth to all hosts
54b578218776 is described below

commit 54b57821877631f7ad54625ecdd5d636b6655a02
Author: Andrea Cosentino <[email protected]>
AuthorDate: Mon Sep 21 21:06:36 2026 +0200

    CAMEL-24815: camel-opensearch - honour socketTimeout without SSL and scope 
basic auth to all hosts
    
    Two divergences from the camel-elasticsearch producer: socketTimeout
    was only applied inside the SSL branch, so a plain-HTTP node could
    block the calling thread indefinitely; and basic-auth credentials were
    registered with an AuthScope bound to the first host, so requests
    routed to any other node of a multi-host cluster got HTTP 401.
    
    The request-config callback now sets the response timeout for both
    plain and SSL connections, and the credentials use a match-all
    AuthScope so they reach every node.
    
    Closes #26589
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
---
 .../org/apache/camel/component/opensearch/OpensearchProducer.java  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-opensearch/src/main/java/org/apache/camel/component/opensearch/OpensearchProducer.java
 
b/components/camel-opensearch/src/main/java/org/apache/camel/component/opensearch/OpensearchProducer.java
index c25efe389fa2..f90f6314a1ca 100644
--- 
a/components/camel-opensearch/src/main/java/org/apache/camel/component/opensearch/OpensearchProducer.java
+++ 
b/components/camel-opensearch/src/main/java/org/apache/camel/component/opensearch/OpensearchProducer.java
@@ -486,11 +486,14 @@ class OpensearchProducer extends DefaultAsyncProducer {
         final RestClientBuilder builder = 
RestClient.builder(configuration.getHostAddressesList().toArray(new 
HttpHost[0]));
 
         builder.setRequestConfigCallback(requestConfigBuilder -> 
requestConfigBuilder
-                
.setConnectTimeout(Timeout.of(Duration.ofMillis(configuration.getConnectionTimeout()))));
+                
.setConnectTimeout(Timeout.of(Duration.ofMillis(configuration.getConnectionTimeout())))
+                // apply the socket/read timeout for both plain-HTTP and SSL 
connections, not only when SSL is enabled
+                
.setResponseTimeout(Timeout.of(Duration.ofMillis(configuration.getSocketTimeout()))));
         builder.setHttpClientConfigCallback(httpClientBuilder -> {
             if (ObjectHelper.isNotEmpty(configuration.getUser()) && 
ObjectHelper.isNotEmpty(configuration.getPassword())) {
                 final BasicCredentialsProvider credentialsProvider = new 
BasicCredentialsProvider();
-                credentialsProvider.setCredentials(new 
AuthScope(configuration.getHostAddressesList().get(0)),
+                // match-all AuthScope so basic auth is sent to every node, 
not only the first configured host
+                credentialsProvider.setCredentials(new AuthScope(null, null, 
-1, null, null),
                         new 
UsernamePasswordCredentials(configuration.getUser(), 
configuration.getPassword().toCharArray()));
                 
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
             }

Reply via email to