allthingssecurity opened a new pull request, #28433:
URL: https://github.com/apache/camel/pull/28433

   # Description
   
   [CAMEL-25909](https://issues.apache.org/jira/browse/CAMEL-25909)
   
   `Kinesis2Component` holds one `KinesisConnection` for all its endpoints. The 
connection caches the client of the first endpoint that asks for one and gives 
it to every other aws2-kinesis endpoint, so:
   
   - an endpoint runs with the region, credentials and endpoint override of 
another endpoint (`region=eu-west-1&accessKey=b...` next to 
`region=us-east-1&accessKey=a...` reads and writes in us-east-1 with the 
credentials of `a`);
   - an endpoint's own `amazonKinesisClient` is ignored once another endpoint 
has started: its records go through the other endpoint's client;
   - `Kinesis2Endpoint.doStop` closes the shared client and the connection 
keeps the closed instance. After one aws2-kinesis endpoint stops (its route is 
removed, routes are reloaded, a kamelet route is removed), every other 
aws2-kinesis producer and consumer fails with `Connection pool shut down` until 
the context restarts;
   - the component's `doStop` closes a client that the user set on the 
component.
   
   This was reported as item 4 of the camel-aws2-kinesis section of 
CAMEL-24156. #24863 only cleared the fields of `KinesisConnection.close()` at 
component stop.
   
   Changes:
   - Each `Kinesis2Endpoint` has its own `KinesisConnection` and gives it to 
its producer and consumer. `doStop` closes it, and a later start creates new 
clients.
   - `KinesisConnection` records which clients it created and closes only 
those, never a client set with `amazonKinesisClient` / 
`amazonKinesisAsyncClient` (on the endpoint or the component).
   - `Kinesis2Component.getConnection()` is kept and documented as not used by 
the endpoints (unit tests wire consumers with it); no option or generated file 
changes.
   - Not tested separately: the KCL consumer, which takes the endpoint's async 
client (now the endpoint's own).
   - Upgrade note in the 4.24 guide: a client set by the user (on the component 
or an endpoint) is no longer closed by Camel.
   
   Tests:
   - New `KinesisEndpointClientTest` (5 tests, JUnit assertions and Mockito as 
in the module). All 5 fail on main: two endpoints get the same client (sync), 
the second async client has the region of the first (`expected: <eu-west-1> but 
was: <us-east-1>`), `putRecord` goes to the other endpoint's client, after 
`removeRoute("a")` route `b` fails with `IllegalStateException: Connection pool 
shut down`, and the component's client is closed at context stop.
   - camel-aws2-kinesis unit tests: 51 run, 0 failures. Formatter and import 
sort ran. Built offline with `-Daws-java-sdk2-version=2.55.15` because the 
2.56.0 of main was not in my local repository.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-25909](https://issues.apache.org/jira/browse/CAMEL-25909).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built camel-aws2-kinesis and ran its tests, including the formatter and 
import-sort plugins. There are no generated file changes. I did not run the 
full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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