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

   # Description
   
   [CAMEL-26893](https://issues.apache.org/jira/browse/CAMEL-26893): adding 
routes with explicit ids slows quadratically.
   
   `AbstractCamelContext.removeRoute(String, LoggingLevel)` built the 
`endpointsInUse` map by calling `gatherEndpoints()` on every `RouteService`, 
before it looked up the route to remove. When the id was unknown, or the route 
was still started, the map was thrown away. 
`DefaultModel.removeRouteDefinition` calls `removeRoute(id)` for every route 
definition added with an id, so each added route walked the child services of 
every route already in the context: O(n²) for n routes added with ids.
   
   This builds the map only in the branch that actually removes a stopped 
route, still before `doRemove()` shuts that route down, so what is gathered and 
which private endpoints are removed are unchanged. `doRemove()` is the only 
consumer of the map.
   
   # Tests
   
   New `RouteRemoveGatherEndpointsTest` in camel-core. The route under test 
contains a processor that is an `EndpointAware` service, counting how often its 
endpoint is gathered:
   
   - `removeRoute()` of an unknown id or of a started route gathers nothing, 
and removing the route once it is stopped still gathers its endpoints and 
removes it;
   - adding a route with an explicit id does not gather the endpoints of the 
existing route.
   
   Both tests fail without the change (`expected: <0> but was: <1>`). The 156 
camel-core tests that call `removeRoute` or `removeRouteDefinition` pass, 
including the new ones. `formatter:format impsort:sort` leaves the change 
unchanged.
   
   No user-visible behaviour changes, so there is no upgrade guide entry.
   
   # 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).
   
   I asked on the JIRA issue to be assigned, as my new JIRA account cannot 
assign issues yet.
   
   _Claude Code on behalf of Ayush0612005_
   


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