tjwatson commented on PR #334: URL: https://github.com/apache/felix-dev/pull/334#issuecomment-3004612967
> @tjwatson I am not 100% sure but I think we discussed how to handle multiple references to a single prototype from one component in the spec group and decided to handle this as a single reference which is then injected into the various fields/methods. I see that in https://docs.osgi.org/specification/osgi.cmpn/8.1.0/service.component.html#service.component-reference.scope which says: > prototype_required - For all references to a given bound service, each activated component instance must use a single, distinct service object. That is, for a given bound service, each component instance will use a distinct service object but within a component instance all references to the bound service will use the same service object. But the problem is then later the spec says this which has some contradiction: > For a bound service of a reference with prototype or prototype_required reference scope, SCR must use a Service Objects object obtained from the OSGi Framework's service registry using the component's Bundle Context to get any service objects. If service objects for a bound service have been obtained and the service becomes unbound, SCR must unget any unreleased service objects using the Service Objects object obtained from the OSGi Framework's service registry using the component's Bundle Context. This means that if a component instance used a Component Service Objects object to obtain service objects, SCR must track those service objects so that when the service becomes unbound, SCR can unget any unreleased service objects. The problem is implementing this `unget` of the service objects when the service is "unbound". What is suppose to happen if the same service is injected into more than one reference for a component but later only one is "unbound" from a dynamic optional reference? What the implementation does is `unget` all instances of the service object which is the same instance still bound to the other references. This is what leads to the problem. Once the other references un "unbound" SCR still has a reference to the injected object and it ungets it again. If we had instead let each reference get its own managed instance this would not be a problem. But as it stands now we have this problem where we are ungetting service objects when we shouldn't while there are still other references in the component that still need the service object. -- 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: dev-unsubscr...@felix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org