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

Tom Watson commented on FELIX-6726:
-----------------------------------

 
{quote}Even calling it twice should not cause the Exception.
{quote}
While I think there is a framework issue here I don't agree with this 
statement.  Once the service object is passed to unget then the framework must 
NOT keep any record (reference) to the object passed in.  If that same object 
is passed in again then the framework has no real choice but to assume it is an 
"unknown" object because it no longer has references to the object.  What I 
view as a framework issue is that the framework is firing a framework error 
here AND throwing an exception to the caller.  I see no need to fire a 
framework error event (which gets logged) AND throw the exception to the 
caller.  The caller can chose what to do with the exception (ignore, log, 
propagate etc.).  For SCR we are just trying to clean up and should not view 
this as an error and should be able to safely ignore it, which is what SCR 
currently does for calls to unget.

> 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