allthingssecurity commented on PR #28710:
URL: https://github.com/apache/camel/pull/28710#issuecomment-6518445879
@davsclaus thanks, all in 6416ceb25b02:
- Components created with `autoStart=false` are now tracked as you
suggested. Inside the `computeIfAbsent` mapping function, a component created
with `autoStart=false` is put in a `componentsCreatedWithoutAutoStart` map
(name -> component), so it is marked before any other thread can get it. The
new branch skips a component found there by identity. `removeComponent` removes
the entry with `remove(name, old)`, and context stop clears the map next to
`components.clear()`. BUILT is still covered for the race, because a component
created with `autoStart=true` is not in the map. New tests:
- `testOtherThreadStartsTheComponentThatItsCreatorHasNotStartedYet`: the
creator is held at the "Start Component" step, so the component is BUILT and
not started yet. The other thread starts it and creates its endpoint on a
started component. Fails on main.
- `testComponentCreatedWithoutAutoStartIsNotStartedByAnotherThread`:
`getComponent("slow", true, false)` and then a plain `getComponent("slow")`
from another thread. The component stays BUILT until its creator starts it.
Fails on the first commit.
- So `RestProducerFactoryHelper.setupComponent` and
`RouteBuilder.customize` behave as on main.
- Not changed, same as main: a component that `customize` creates on an
already started context (routes added at runtime) is never started by anyone,
so the race stays open for it. A small follow-up would be for `customize` to
start the component after `code.apply` when the context is already started.
- The branch now uses the context's `startService(component)`. In the race
both threads register a `StartupListener` component. The duplicate is harmless
for the two components in the repo that are one (`QuartzComponent`,
`QuickfixjComponent`), and the same duplicate already happens on main while the
context starts.
- Code comment on the lock-ordering edge: the thread waits for the
component's service lock, possibly while it holds the CamelContext lock. So a
component's `doStart` must not take the CamelContext lock (adding or starting
routes), nor get a component whose `doStart` gets it back.
- Tests: camel-core component lookup, rest, `*CamelContext*Test` and
`CamelContextDeadlockTest`, 2900 tests: per class the same as main except the
race tests. `ComponentStartedBeforeUseTest` and `CamelContextDeadlockTest` pass
20 runs in one JVM. A mutant without the `BUILT` check fails the new BUILT test.
- Renamed the local to `startingContext`.
- `isNotStartedYet` returns `false` first when the component is started.
PR body updated to match.
_Claude Code on behalf of allthingssecurity_
--
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]