oscerd opened a new pull request, #31116:
URL: https://github.com/apache/camel/pull/31116
## Description
`SingletonService.addToStore` registered a JVM shutdown hook on every
`beforeAll`, outside the `computeIfAbsent` that
initializes the singleton once. A singleton service used by several test
classes was therefore shut down as many times,
by hooks that the JVM runs at the same time. Croway found it in the review
of #29245, and again in #30191, where seven
BigQuery test classes made seven hooks race to remove the same floci-duck
container (`ConflictException: removal of
container ... is already in progress`).
This PR:
- registers the hook once, when the singleton is initialized, through a new
protected `registerShutdownHook()` that
`doInitializeService` calls after `initialize()`. A service whose
initialization fails gets no hook, as before;
- drops the guard of `AzureEventHubsLocalContainerInfraService` (a `started`
flag and a `synchronized shutdown()`), which
#29245 added only because of the concurrent hooks. Its `initialize()`
still shuts the service down when it fails, and
a second shutdown, by `afterAll` of a non-singleton service, only stops a
stopped container;
- adds `SingletonServiceTest`: the singleton is registered on the test class
and inherited by two nested classes, so
three test classes use it. The service is initialized once, and one
shutdown hook is registered.
## Testing
- camel-test-infra-common: the 27 tests pass. `SingletonServiceTest` fails
without the fix, on
`one shutdown hook is registered, however many test classes use the
service ==> expected: <1> but was: <3>`.
- camel-azure-eventhubs: the integration tests pass against Floci AZ without
the guard.
- Full reactor build.
_Claude Code on behalf of Andrea Cosentino_
🤖 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]