Community
Participate
Working Groups
EclipseContextOSGi gets all services that implement IContextFunction and stores them by their service.context.key property. If there are multiple services with the same context key, the last one loaded will overwrite the others. This has two consequences: 1. It does not respect the service.ranking property. In fact, because the services references are ordered by the service ranking when returned from the bundle context, it will actually use the service with the lowest ranking. 2. In the constructor when processing existing services, no check is made to see if an existing service reference is stored for a given context key, therefore ungetService is never called. This is handled properly in the serviceChanged handler. Workaround: because the service with the lowest ranking overwrites all others, setting a lower service.ranking allows control of which is used.
Created attachment 229108 [details] Proposed patch to track service.ranking and ungetService when replacing
Created attachment 229113 [details] Proposed patch to track service.ranking and ungetService when replacing existing Fixed bug in patch
Wouldn't it be better to just store the valid service refs sorted in some way instead of just storing one? PW
Fix looks good to me, having the one with the highest number injected is definitely an improvement against current behavior.
Increasing prio, I think getting the lowest prio service is relatively critical.
It needs to be reconsidered. First off, we don't keep track of the refs (just one we've determined). Also, there's a section in the patch that says FIXME ... should be fixed. PW
I think this is a dup of Bug 429466 *** This bug has been marked as a duplicate of bug 429466 ***