[ 
https://issues.apache.org/jira/browse/FELIX-6726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17881322#comment-17881322
 ] 

Jürgen Albert commented on FELIX-6726:
--------------------------------------

After some discussion with [~tjwatson], we determined that this is more an 
issue of the Framework and not of SCR directly. According to the [unget 
doc|https://github.com/osgi/osgi/blob/51fb5bd473d706bd30a62eacef71aac5fcc9eb03/org.osgi.framework/src/org/osgi/framework/ServiceObjects.java#L127-L134],
 the Exception should only be thrown, if it is called by an object, not 
provided by the ServiceObjects for the associated service. Even calling it 
twice should not cause the Exception.

> One reference can be unset more then once and will cause 
> IllegalStateException in Framework
> -------------------------------------------------------------------------------------------
>
>                 Key: FELIX-6726
>                 URL: https://issues.apache.org/jira/browse/FELIX-6726
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions: framework-7.0.5, scr-2.2.12
>            Reporter: Jürgen Albert
>            Priority: Major
>
> We have a Component Foo registered under Interface A and B. A also extends B.
> A Prototype Component Bar references the Service under its interface A.
> When the prototype instance is cleaned up, the DependencyManager of SCR calls 
> unget for the instance Foo 2 times, because it thinks that the one Instance 
> are 2 RefPairs. One under the Interface A and one under B. Unget is now 
> called by the DependencyManager 2 times but the Framework only knows about 
> one usage. In this case the IllegalState Exception is thrown.
> The relevant parts of the Stacktrace:
> {code}
> ERROR: Bundle de.jena.udp.modelling.ui.api [20] ServiceRegistrationImpl: 
> Error ungetting service. (java.lang.IllegalArgumentException)
>       at 
> org.apache.felix.framework.BundleContextImpl$ServiceObjectsImpl.ungetService(BundleContextImpl.java:564)
>       at 
> org.apache.felix.scr.impl.helper.ComponentServiceObjectsHelper$ComponentServiceObjectsImpl.ungetService(ComponentServiceObjectsHelper.java:214)
>       at 
> org.apache.felix.scr.impl.manager.AbstractPrototypeRefPair.doUngetService(AbstractPrototypeRefPair.java:103)
>       at 
> org.apache.felix.scr.impl.manager.AbstractPrototypeRefPair.ungetServiceObject(AbstractPrototypeRefPair.java:67)
>       at 
> org.apache.felix.scr.impl.manager.DependencyManager.close(DependencyManager.java:1964)
>       at 
> org.apache.felix.scr.impl.manager.SingleComponentManager.disposeImplementationObject(SingleComponentManager.java:430)
>       at 
> org.apache.felix.scr.impl.manager.ServiceFactoryComponentManager.ungetService(ServiceFactoryComponentManager.java:177)
>       at 
> org.apache.felix.framework.ServiceRegistrationImpl.ungetFactoryUnchecked(ServiceRegistrationImpl.java:393)
>       at 
> org.apache.felix.framework.ServiceRegistrationImpl.ungetService(ServiceRegistrationImpl.java:288)
>       at 
> org.apache.felix.framework.ServiceRegistry.ungetService(ServiceRegistry.java:517)
>       at org.apache.felix.framework.Felix.ungetService(Felix.java:3996)
>       at 
> org.apache.felix.framework.BundleContextImpl$ServiceObjectsImpl.ungetService(BundleContextImpl.java:562)
>       at 
> org.eclipse.osgitech.rest.factories.JerseyResourceInstanceFactory.disposeInstance(JerseyResourceInstanceFactory.java:115)
>       at 
> org.eclipse.osgitech.rest.factories.JerseyResourceInstanceFactory.dispose(JerseyResourceInstanceFactory.java:52)
>       at 
> org.jvnet.hk2.internal.FactoryCreator.dispose(FactoryCreator.java:153)
>       at 
> org.jvnet.hk2.internal.SystemDescriptor.dispose(SystemDescriptor.java:521)
>       at 
> org.glassfish.jersey.inject.hk2.RequestContext.lambda$findOrCreate$0(RequestContext.java:60)
>       at 
> org.glassfish.jersey.internal.inject.ForeignDescriptorImpl.dispose(ForeignDescriptorImpl.java:63)
>       at 
> org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.remove(Hk2RequestScope.java:126)
>       at java.base/java.lang.Iterable.forEach(Iterable.java:75)
>       at 
> org.glassfish.jersey.inject.hk2.Hk2RequestScope$Instance.release(Hk2RequestScope.java:143)
>       at 
> org.glassfish.jersey.process.internal.RequestScope.release(RequestScope.java:246)
>       at 
> org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:267)
>       at 
> org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:240)
>       at 
> org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
>       at 
> org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
>       at 
> org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
>       at 
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
>       at 
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
>       at 
> org.eclipse.osgitech.rest.runtime.WhiteboardServletContainer.service(WhiteboardServletContainer.java:137)
>       at 
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
>       at 
> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:128)
>       at 
> org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:86)
>       at 
> org.apache.felix.http.base.internal.dispatch.Dispatcher$1.doFilter(Dispatcher.java:153)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to