-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Unregister service value error bug #345
Conversation
My initial attempted solution is flawed as we dont actually want to lister for all unregistered services, but instead only those which were contributed as service offers to the Also note the comment here:
|
… via the CorePlugin's service_offers extension point
The |
To elaborate... a more obviously correct fix is to implement |
So basically, what happened previously was that
So, when For reference,
It would also be a valid approach to define a Note that if a service offer is not unregistered while the application is running then without any of the changes made in this PR, they will still be unregistered when |
Thank you @aaronayres35. Looks like we are having more than one sources of truth here. Both the service registry on the application and the individual plugin are trying to manage the life-time of a service, so they could end up stepping on each other's toes, and causing a service to be unregistered twice (or more times). Eliminating multiple sources of truth would be a better fix. Otherwise, we are going to have to do more of these sychronization, e.g. not just |
Another alternative approach to consider may be for plugins to anticipate that when it tries to unregister a service, it may have already been unregistered by others, and handle the exception there. |
Ah, this would present a mental shift in understanding... The service ids on the plugins provide no indications as to whether the service is still used or not, they are mere references. The service registry is the one that has that information. Plugins are keeping these ids so that if they are independently deactivated, they can ask the service registry to unregister its service offers. If this understanding holds, it would make sense for a plugin to expect and handle the exception when attempt to unregister a service fails because it is already gone. |
I see, maybe we could have a quick chat about this either before, after or during the standup today? Just to make sure my understanding is on the same page.
and I removed my listener in |
…egister a service would fail because it has already been unregistered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments and questions.
(The test looks great, they are not junk 😂 .)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fixes #251
This PR first adds a failing regression test for the error described in the issue.
To fix the issue, I added a listener in the
CorePlugin
class that listens to theservice_registry
'sunregistered
event trait. As mentioned in the issue, whenApplication.unregister_service(<id>)
was called, the id was not also removed fromCorePlugin._service_ids
, so in the handler we simply remove the unregistered service id fromself._service_ids
.