jbonofre commented on code in PR #739:
URL: https://github.com/apache/camel-karaf/pull/739#discussion_r3872608029
##########
core/camel-core-osgi/src/main/java/org/apache/camel/karaf/core/OsgiTypeConverter.java:
##########
@@ -99,9 +138,21 @@ public Object
addingService(ServiceReference<TypeConverterLoader> serviceReferen
public void modifiedService(ServiceReference<TypeConverterLoader>
serviceReference, Object o) {
}
+ // not synchronized, for the same reason as addingService
@Override
public void removedService(ServiceReference<TypeConverterLoader>
serviceReference, Object o) {
LOG.trace("RemovedService: {}, Bundle: {}", serviceReference,
serviceReference.getBundle());
+ trackedLoaders.remove(serviceReference);
+ // we took the service in addingService, so releasing it is ours to do
+ ungetQuietly(serviceReference);
+ if (this.delegate != null && !isStopping() && !isStopped()) {
Review Comment:
**`!isStopped()` also suppresses this warning in every pre-`STARTED` state,
so the diagnostic #734 asked for is missing exactly in the lazy-init window
this class documents.**
From `BaseService` (camel-api 4.18):
```java
public boolean isStopped() {
return status < STARTING || status >= STOPPED;
}
```
with `NEW = 0, BUILT = 1, INITIALIZING = 2, INITIALIZED = 3, STARTING = 4
... STOPPED = 9 ... FAILED = 12`.
So `isStopped()` is `true` for `NEW`, `BUILT`, `INITIALIZING`, `INITIALIZED`
and `FAILED` — not just after a stop. `getDelegate()`'s own comment below says
it "may be called during `doInit()` ... which happens before `doStart()`". An
`OsgiTypeConverter` that is already serving conversions but has not reached
`STARTED` will therefore discard its registry on a loader unregistration with
**no log line at all**, which is the invisibility this PR exists to remove.
`isStopping()` alone already achieves the stated goal (no line-per-loader on
`tracker.close()`, since `stop()` sets `status = STOPPING` before calling
`doStop()`). The `&& !isStopped()` half is what breaks it; if a post-stop guard
is also wanted, `status != STOPPED` is the narrow form.
--
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]