Do not expose unstarted service, stop started service leak#938
Conversation
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
|
This is ready for review |
| prevService.stop(); | ||
| if (prevService == service) { | ||
| agentServices.remove(serviceName, prevService); | ||
| throw new IllegalArgumentException("Double registration"); //$NON-NLS-1$ |
There was a problem hiding this comment.
Is it anywhere mentioned that this is not allowed? Also it would be more an illegalstate than an illegal argument and the message should be more descriptive.
There was a problem hiding this comment.
Please see line 99.
if (service instanceof IAgentService) {
((IAgentService) service).start();
}
If double registration was allowed, IAgentService.start() would be invoked twice for the same object.
My original idea was to just unregister existing service, but for the case of double registration, this would leave stopped service in the registry.
I've enhanced the error message with the key, value and explanation.
There was a problem hiding this comment.
I've fixed a concurrency bug - the service should only be stopped after removal from the registry.
There was a problem hiding this comment.
If double registration was allowed, IAgentService.start() would be invoked twice for the same object.
This is an implementation detail and can of course be avoided, so the question is if anywhere is documented that registering the same service twice is forbidden (at least it was not before)
There was a problem hiding this comment.
I've extended the Javadoc.
|
Build is currently failing, maybe squash / rebase? |
- Ensure that services registered in ProvisionalAgent are disposed when replaced with an alternative. - Ensure services are not exposed to clients until started
Jenkins build is failing with an unclear error: How do I fix this? |
|
This was happening the other week on other servers after the storage migration. 😢 I'll try to kick it again. (The fact that all the GHA tests passed is maybe good enough, but let's try again.) |
|
It seems stalled just like the previous build. I'm not sure if we need to report it. I asking around... |
|
Thanks to your rapid response team, i.e., @fredg02, the build is running again. 🚀 |
There is a potential for client to see service before they are started.
Dynamically registered services may be never stopped causing resource leaks.
This is a part of #939 in context of #937.