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

   ## Summary
   
   Fixes [CAMEL-25620](https://issues.apache.org/jira/browse/CAMEL-25620).
   
   `DefaultDevConsoleRegistry` kept its consoles in an unsynchronised 
`TreeSet`. `doStart()` iterates that set, while `register()` (also called from 
`resolveById()`) adds to it. With `camel-cli-connector` enabled, the connector 
task runs with an initial delay of 0 and resolves consoles from its own thread, 
so it could add a console while `CamelContext` was starting the registry. The 
iteration then failed with `ConcurrentModificationException` and `CamelContext` 
did not start (intermittently, depending on thread timing).
   
   ## Changes
   
   - The registry uses a `ConcurrentSkipListSet` sorted by console id. 
Iteration is weakly consistent, so registering during 
`doInit`/`doStart`/`doStop` no longer fails. A console registered late is still 
started by `register()` itself, as before. `add` is atomic per id, so the same 
id cannot be registered twice.
   - `resolveById()`: when two threads resolve the same console at once, the 
one that loses the `register()` race now returns the console that was 
registered, not an unregistered copy.
   
   ## Tests
   
   - `DefaultDevConsoleRegistryTest.testRegisterWhileStarting`: a console that 
registers another console when it starts, so a console is added while the 
registry iterates. Without the fix it fails with the same 
`ConcurrentModificationException` as the report.
   - `testRegisterSameIdTwice`: a second console with the same id is rejected 
and the first one is kept.
   - `mvn install` in `core/camel-console`: all tests pass.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 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