Skip to content

CAMEL-24815: camel-opensearch - honour socketTimeout without SSL and scope basic auth to all hosts - #26589

Open
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24815
Open

oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24815

Conversation

@oscerd

@oscerd oscerd commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What

Two divergences in OpensearchProducer.createClient() versus the camel-elasticsearch producer, both affecting real deployments.

1. socketTimeout ignored without SSL

The request-config callback set only setConnectTimeout(...). The socketTimeout option was applied only inside the if (configuration.isEnableSSL()) branch (through the pooling connection manager's ConnectionConfig). So on a plain-HTTP OpenSearch endpoint the configured socketTimeout had no effect and a slow/stalled node could block the calling thread indefinitely. camel-elasticsearch applies both connect and socket timeouts unconditionally.

2. Basic-auth scoped to the first host only

Credentials were registered with new AuthScope(hostAddressesList.get(0)), binding them to the first configured host/port. In a multi-host cluster, requests routed to any other node carried no credentials and were rejected with HTTP 401. camel-elasticsearch uses AuthScope.ANY (match all).

Fix

  • Add setResponseTimeout(...) to the request-config callback so the read timeout is honoured for both plain-HTTP and SSL connections (HttpClient 5 equivalent of the socket timeout).
  • Register the credentials with a match-all AuthScope(null, null, -1, null, null) (the HttpClient 5 idiom, since AuthScope.ANY was removed) so basic auth reaches every node.

Testing

No new unit test: createClient() configures the low-level RestClient's callbacks, and the resulting credential/timeout config is not observable without a live multi-host / authenticated cluster (integration-only). The change makes camel-opensearch match the behaviour already implemented in camel-elasticsearch, and is exercised by the existing OpenSearch integration tests. Verified the module compiles and its unit tests pass.

Notes

  • Logic-only; no public API / @UriParam / generated-catalog change.
  • Backport candidate for camel-4.22.x and camel-4.18.x.

Generated by Claude Code on behalf of Andrea Cosentino (@oscerd).

🤖 Generated with Claude Code

…scope basic auth to all hosts

OpensearchProducer.createClient() diverged from the camel-elasticsearch
producer in two ways:

- socketTimeout was applied only inside the enableSSL branch (via the pooling
  connection manager), so plain-HTTP endpoints ignored it and a stalled node
  could block the caller indefinitely. Add setResponseTimeout to the
  request-config callback so the read timeout applies with and without SSL.
- basic-auth credentials were registered with AuthScope bound to the first
  configured host, so multi-host clusters returned 401 on every other node.
  Use a match-all AuthScope so credentials are sent to all nodes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd added port/camel-4.22.x Bug needs porting to camel-4.22.x port/camel-4.18.x Bug needs porting to camel-4.18.x labels Sep 18, 2026
@oscerd
oscerd requested review from Croway and davsclaus September 18, 2026 10:10
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two correct bug fixes, well-scoped.

Fix 1 — socketTimeout on plain-HTTP: Adding setResponseTimeout(...) to the setRequestConfigCallback chain is the right move. In HttpComponents 5, RequestConfig.responseTimeout is the per-request read-timeout equivalent of HC4's socketTimeout. The SSL branch already sets ConnectionConfig.socketTimeout at the connection-manager level; the two operate at different layers and are complementary. Non-SSL connections now have the same timeout protection as SSL ones.

Fix 2 — AuthScope match-all: new AuthScope(null, null, -1, null, null) is the HC5 idiom for what HC4 exposed as AuthScope.ANY (removed in HC5). Scoping credentials to hostAddressesList.get(0) was a real bug in multi-node clusters — requests routed to other nodes would get 401. This is a direct port of what camel-elasticsearch already does with AuthScope.ANY.

Test coverage: No unit test is added, and that's acceptable here. createClient() produces an opaque RestClient via internal callbacks — the credential scope and timeout values aren't observable without a live cluster. The existing integration tests exercise the runtime path.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@oscerd oscerd self-assigned this Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-opensearch

🔬 Scalpel shadow comparison — Scalpel: 9 tested, 27 compile-only — current: 9 all tested

Maveniverse Scalpel detected 36 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 27 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-opensearch
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (36 modules, 4m 36s total)

Total reactor time: 4m 36s

Module Duration Status
Camel :: Launcher 49.7s SUCCESS
Camel :: JBang :: MCP 38.0s SUCCESS
Camel :: JBang :: Plugin :: TUI 31.9s SUCCESS
Camel :: Catalog :: Camel Catalog 21.8s SUCCESS
Camel :: Component DSL 21.2s SUCCESS
Camel :: Docs 14.3s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 14.2s SUCCESS
Camel :: Catalog :: Camel Report Maven Plugin 9.3s SUCCESS
Camel :: YAML DSL :: Validator 9.0s SUCCESS
Camel :: Kamelet Main 8.8s SUCCESS
Camel :: Catalog :: Camel Route Parser 8.4s SUCCESS
Camel :: JBang :: Plugin :: Testing 7.7s SUCCESS
Camel :: YAML DSL :: Deserializers 6.0s SUCCESS
Camel :: All Components Sync point 5.2s SUCCESS
Camel :: JBang :: Plugin :: Validate 4.6s SUCCESS
Camel :: YAML DSL :: Validator Maven Plugin 4.3s SUCCESS
Camel :: YAML DSL :: Maven Plugins 3.6s SUCCESS
Camel :: Catalog :: Maven 2.7s SUCCESS
Camel :: Catalog :: Suggest (deprecated) 2.5s SUCCESS
Camel :: Assembly 1.9s SUCCESS
Camel :: JBang :: Plugin :: Edit 1.9s SUCCESS
Camel :: Coverage 1.7s SUCCESS
Camel :: JBang :: Integration tests 1.1s SUCCESS
Camel :: JBang :: Plugin :: Generate 1.1s SUCCESS
Camel :: Catalog :: Dummy Component 1.1s SUCCESS
Camel :: Endpoint DSL :: Support 1.0s SUCCESS
Camel :: JBang :: Plugin :: MCP 0.9s SUCCESS
Camel :: Catalog :: Console 0.8s SUCCESS
Camel :: JBang :: Main 0.8s SUCCESS
Camel :: Launcher :: Container 0.7s SUCCESS
Camel :: JBang :: Plugin :: Route Parser 0.5s SUCCESS
Camel :: Endpoint DSL n/a
Camel :: Integration Tests n/a
Camel :: JBang :: Core n/a
Camel :: OpenSearch Java API Client n/a
Camel :: YAML DSL n/a

Top 20 slowest modules:

  • Camel :: Launcher (49.7s)
  • Camel :: JBang :: MCP (38.0s)
  • Camel :: JBang :: Plugin :: TUI (31.9s)
  • Camel :: Catalog :: Camel Catalog (21.8s)
  • Camel :: Component DSL (21.2s)
  • Camel :: Docs (14.3s)
  • Camel :: JBang :: Plugin :: Kubernetes (14.2s)
  • Camel :: Catalog :: Camel Report Maven Plugin (9.3s)
  • Camel :: YAML DSL :: Validator (9.0s)
  • Camel :: Kamelet Main (8.8s)
  • Camel :: Catalog :: Camel Route Parser (8.4s)
  • Camel :: JBang :: Plugin :: Testing (7.7s)
  • Camel :: YAML DSL :: Deserializers (6.0s)
  • Camel :: All Components Sync point (5.2s)
  • Camel :: JBang :: Plugin :: Validate (4.6s)
  • Camel :: YAML DSL :: Validator Maven Plugin (4.3s)
  • Camel :: YAML DSL :: Maven Plugins (3.6s)
  • Camel :: Catalog :: Maven (2.7s)
  • Camel :: Catalog :: Suggest (deprecated) (2.5s)
  • Camel :: Assembly (1.9s)

⚙️ View full build and test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components port/camel-4.18.x Bug needs porting to camel-4.18.x port/camel-4.22.x Bug needs porting to camel-4.22.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants