gnodet commented on PR #30505: URL: https://github.com/apache/camel/pull/30505#issuecomment-7104153692
Thank you for the thorough follow-up, @davsclaus. **On the `setConnectionManagerShared(true)` side effect (latest commit bc6727b)** You're right — leaving `connManagerShared=true` on the builder after the token client is built meant the endpoint's own client (built from the same builder at `HttpEndpoint.createHttpClient():384`) would also inherit the shared flag. In HC5 `HttpClientBuilder.build()` only starts `IdleConnectionEvictor` when `connManagerShared` is false, so an endpoint configured with `evictIdleConnections`/`evictExpiredConnections` via a custom `HttpClientConfigurer` would silently lose eviction. The fix: after building the token client, `configureHttpClient()` now resets `clientBuilder.setConnectionManagerShared(false)`. `HttpEndpoint.createHttpClient()` already sets it back to `true` on its own when the endpoint uses the component's shared manager (line 305–307), so the restore to `false` is always safe and correct. **On the JIRA reproducer** You noted that `camel run` is not available in this environment, so a direct YAML test is not possible. The mechanism is nonetheless clear from the code: 1. `HttpClientBuilder.build()` appends the `PoolingHttpClientConnectionManager` to `InternalHttpClient`'s closeables list only when `connManagerShared=false` (see [HC5 source](https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java)). 2. Before the fix: both token client and endpoint client were built with `connManagerShared=false` ⇒ both had the shared pool in their closeables ⇒ closing the token client shut down the pool ⇒ the subsequent API request (or the first request if the endpoint was reconfigured) got `IllegalStateException: Connection pool shut down`. 3. After the fix: the token client is built with `connManagerShared=true` ⇒ the pool is not in its closeables ⇒ closing the token client is a no-op for the pool ⇒ the endpoint's pool remains operational. `tokenClientCloseDoesNotShutDownEndpointPool` directly tests step 3: it simulates the full configurer lifecycle (start → configureHttpClient → build endpoint client → stop configurer) and verifies that `endpointConnManager.lease()` does not throw after the token client is closed. If you'd like to run the YAML reproducer from the JIRA against this branch, that would be appreciated — but the code path analysis fully accounts for the reported failure. _Guillaume Nodet_ -- 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]
