[
https://issues.apache.org/jira/browse/CAMEL-27233?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Guillaume Nodet reassigned CAMEL-27233:
---------------------------------------
Assignee: Guillaume Nodet
> camel-http - with OAuth2, a token endpoint on the same host and port as the
> API shuts down the connection pool, and the request fails
> -------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27233
> URL: https://issues.apache.org/jira/browse/CAMEL-27233
> Project: Camel
> Issue Type: Bug
> Components: camel-http
> Reporter: Claus Ibsen
> Assignee: Guillaume Nodet
> Priority: Major
>
> h3. Problem
> With the OAuth2 options of an http endpoint ({{oauth2ClientId}},
> {{oauth2ClientSecret}}, {{oauth2TokenEndpoint}}), when the token endpoint is
> on the same host and port as the API, the token is fetched but the call to
> the API then fails:
> {noformat}
> HttpRequestRetryExec : recoverable I/O exception (java.net.SocketException)
> caught when sending request to http://127.0.0.1:18099
> TimerConsumer : Error processing exchange. Caused by:
> [java.lang.IllegalStateException - Connection pool shut down]
> java.lang.IllegalStateException: Connection pool shut down
> at
> org.apache.hc.core5.pool.StrictConnPool.lease(StrictConnPool.java:170)
> at
> org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.lease(PoolingHttpClientConnectionManager.java:366)
> ...
> at
> org.apache.camel.component.http.HttpProducer.executeMethod(HttpProducer.java:526)
> {noformat}
> The API never receives the request. Many services serve their token endpoint
> on the same host as the API, such as {{https://api.example.com/oauth/token}}.
> h3. Reproduce
> Camel 4.24.0-SNAPSHOT (2026-11-19), {{camel run}}, against a local HTTP/1.1
> server that answers {{POST /token}} with
> {{\{"access_token":"OAUTH-TOKEN","token_type":"Bearer","expires_in":3600\}}}
> and {{GET /items}} with 200:
> {code:yaml}
> - route:
> from:
> uri: timer:t
> parameters: {repeatCount: 2, period: 1000}
> steps:
> - setHeader: {name: CamelHttpMethod, constant: GET}
> - to:
> "http://127.0.0.1:18099/items?oauth2ClientId=cid&oauth2ClientSecret=csecret&oauth2TokenEndpoint=http://127.0.0.1:18099/token"
> {code}
> ||Token endpoint||Result||
> |same host and port as the API ({{127.0.0.1:18099}})|token fetched, then
> {{Connection pool shut down}}; the API gets nothing|
> |another port ({{127.0.0.1:18098}})|works: both requests carry
> {{Authorization: Bearer OAUTH-TOKEN}}|
> The same happens through the {{http-sink}} Kamelet, which passes these
> options to the http endpoint.
> h3. Possible cause (not confirmed)
> {{OAuth2ClientConfigurer.configureHttpClient}} builds the client for the
> token requests from the same {{HttpClientBuilder}} as the endpoint's client
> ({{this.httpClient = clientBuilder.build()}}), so both clients share one
> connection manager. With the same route for both requests, the token request
> and the API request use the same pool, and the API request then finds it shut
> down. A token client with its own connection manager would avoid it.
> _Claude Code on behalf of Claus Ibsen_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)