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

   # Description
   
   [CAMEL-25839](https://issues.apache.org/jira/browse/CAMEL-25839)
   
   With toD (or recipientList) and `cacheSize=-1`, every call resolves a new 
endpoint and discards it after use, which the toD documentation recommends when 
the endpoint is different for every message. For a Kamelet, each new `kamelet:` 
endpoint creates a route from the template when it is initialized, with a new 
uuid in the route id, and nothing removed that route when toD discarded the 
endpoint. So every message left one more route, and its `kamelet:source` 
endpoint, in the CamelContext until it stopped, even when every message used 
the same parameter values.
   
   Changes (`KameletComponent`):
   - The Kamelet endpoint remembers the route it created while the context runs 
(`LifecycleHandler.track` now returns the id of a route it created at once).
   - When such an endpoint is shut down, as toD and recipientList do for a 
discarded endpoint, it stops and removes that route; the route's private 
`kamelet:source` endpoint goes with it.
   
   Endpoints kept in the endpoint registry (toD with a cache, the default) are 
not shut down while the context runs, so their routes are kept and reused as 
before. Nothing is removed while the context stops. Removing a route logs the 
usual INFO lines of a route stop and removal. No option or default changes.
   
   Tests:
   - New `KameletToDRoutesNotKeptTest` (3 tests). 
`routesOfDiscardedKameletEndpointsAreRemoved` (50 distinct values, toD with 
`cacheSize=-1`) and `sameValueEveryTimeDoesNotKeepRoutes` (50 messages, one 
value) fail without the change: `expected: <0> but was: <50>` routes created by 
the Kamelet. With the change both pass, every reply is checked, and only the 3 
endpoints of the routes stay registered. 
`cachedKameletEndpointsKeepTheirRoutes` (toD with the default cache) passes 
before and after: the 2 routes of the 2 cached endpoints are kept.
   - camel-kamelet unit tests with the change: 143 run, 0 failures, 3 skipped.
   
   How it was found: a sweep for state that grows per message (routes, 
endpoints, services and listeners created on a message path and never removed), 
then the test above.
   
   # 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-25839](https://issues.apache.org/jira/browse/CAMEL-25839).
   
   # 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 and tested camel-kamelet. No option or generated metadata 
changed. 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