Hi all,
We faced a deadlock issue with iPojo 1.6.4 (and also reproduced with iPojo
1.8.0).
Here are the details of the context:
1) We have a first iPojo Component that we will call "PDP".
This Component is declared with the 3 iPojo annotations "Component",
"Instantiate" and "Provides".
2) We have a second iPojo Component that we will call "PEP".
This Component is declared with the 3 iPojo annotations "Component",
"Instantiate" and "Provides".
This Component requires the "PDP" Component with a "@Requires(policy =
"dynamic-priority")" annotation.
In a public method of the "PEP" Component we try to access to a method of the
"PDP" reference.
During some tests, we are facing the following deadlock problem:
2011-02-28 16:38:12,379 - [Thread Monitor] WARN
(WatcherActivator.deadlockDetected:70) - Thread Deadlock detected...
2011-02-28 16:38:12,379 - [Thread Monitor] WARN
(WatcherActivator.deadlockDetected:71) - Deadlocked Thread:
"AsyncRequest-1" Id=87 BLOCKED on
org.apache.felix.ipojo.handlers.providedservice.ProvidedService@1664cb5 owned
by "Thread-7" Id=29
at
org.apache.felix.ipojo.handlers.providedservice.ProvidedService.update(ProvidedService.java:446)
- blocked on
org.apache.felix.ipojo.handlers.providedservice.ProvidedService@1664cb5
at
org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.__onSet(ProvidedServiceHandler.java:432)
at
org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.onSet(ProvidedServiceHandler.java)
at
org.apache.felix.ipojo.InstanceManager.onSet(InstanceManager.java:1102)
at
com.axway.drw.core.defimpl.policy.DefaultPolicyDecisionPoint.__setranking(DefaultPolicyDecisionPoint.java)
at
com.axway.drw.core.defimpl.policy.DefaultPolicyDecisionPoint.<init>(DefaultPolicyDecisionPoint.java:32)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java:601)
org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:777)
org.apache.felix.ipojo.handlers.providedservice.ProvidedService$SingletonStrategy.getService(ProvidedService.java:691)
org.apache.felix.ipojo.handlers.providedservice.ProvidedService.getService(ProvidedService.java:306)
org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:307)
org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:221)
org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:295)
org.apache.felix.framework.Felix.getService(Felix.java:3007)
org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:329)
org.apache.felix.ipojo.IPojoContext.getService(IPojoContext.java:260)
org.apache.felix.ipojo.util.Tracker.getService(Tracker.java:441)
org.apache.felix.ipojo.util.DependencyModel.getService(DependencyModel.java:911)
org.apache.felix.ipojo.handlers.dependency.Dependency.createServiceObject(Dependency.java:631)
org.apache.felix.ipojo.handlers.dependency.Dependency.onGet(Dependency.java:602)
org.apache.felix.ipojo.InstanceManager.onGet(InstanceManager.java:945)
com.axway.darwin.server.core.rest.impl.rest.policy.RestPolicyEnforcementPoint.__getpdp(RestPolicyEnforcementPoint.java)
com.axway.darwin.server.core.rest.impl.rest.policy.RestPolicyEnforcementPoint.__preFilter(RestPolicyEnforcementPoint.java:170)
com.axway.darwin.server.core.rest.impl.rest.policy.RestPolicyEnforcementPoint.preFilter(RestPolicyEnforcementPoint.java)
com.axway.darwin.server.core.rest.impl.rest.InterceptorFilterManager.preFilter(InterceptorFilterManager.java:86)
com.axway.darwin.server.core.rest.impl.rest.InterceptorFilterManager.access$200(InterceptorFilterManager.java:32)
com.axway.darwin.server.core.rest.impl.rest.InterceptorFilterManager$ResourceFilterAdapter.filter(InterceptorFilterManager.java:132)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:270)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
com.sun.jersey.server.impl.uri.rules.ResourceObjectRule.accept(ResourceObjectRule.java:84)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:74)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1347)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1279)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1229)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1219)
com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:180)
com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:145)
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
com.axway.darwin.server.core.rest.impl.rest.JerseyAdapter.service(JerseyAdapter.java:124)
com.axway.darwin.server.core.http.impl.auth.GrizzlyAuthenticationFilter.serveProtectedAdapter(GrizzlyAuthenticationFilter.java:374)
com.axway.darwin.server.core.http.impl.auth.GrizzlyAuthenticationFilter.service(GrizzlyAuthenticationFilter.java:96)
com.axway.darwin.server.core.http.async.AsyncRequest.run(AsyncRequest.java:63)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:662)
2011-02-28 16:38:12,379 - [Thread Monitor] WARN
(WatcherActivator.deadlockDetected:70) - Thread Deadlock detected...
2011-02-28 16:38:12,379 - [Thread Monitor] WARN
(WatcherActivator.deadlockDetected:71) - Deadlocked Thread:
"Thread-7" Id=29 BLOCKED on org.apache.felix.ipojo.util.Tracker$Tracked@a28708
owned by "AsyncRequest-1" Id=87
at
org.apache.felix.ipojo.util.Tracker$Tracked.track(Tracker.java:666)
- blocked on org.apache.felix.ipojo.util.Tracker$Tracked@a28708
at
org.apache.felix.ipojo.util.Tracker$Tracked.serviceChanged(Tracker.java:647)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:864)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:732)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
at
org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3726)
at org.apache.felix.framework.Felix.access$000(Felix.java:80)
at
org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:717)
org.apache.felix.framework.ServiceRegistry.servicePropertiesModified(ServiceRegistry.java:478)
org.apache.felix.framework.ServiceRegistrationImpl.setProperties(ServiceRegistrationImpl.java:116)
org.apache.felix.ipojo.handlers.providedservice.ProvidedService.registerService(ProvidedService.java:348)
org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.__stateChanged(ProvidedServiceHandler.java:494)
org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.stateChanged(ProvidedServiceHandler.java)
org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:441)
org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:322)
org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:155)
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:301)
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:238)
org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCreator.java:343)
org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:89)
org.apache.felix.ipojo.Extender.parse(Extender.java:269)
org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:208)
org.apache.felix.ipojo.Extender.access$600(Extender.java:52)
org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:682)
java.lang.Thread.run(Thread.java:662)
It seems that the 2 threads are trying to modify the same "ProvidedService"
instance: the first one to update the value of the "ServiceRanking" property
and the second one to change its state.
One very important information: we tried to change the way to instantiate the
second Component ("PDP") by using the XML instead of the annotation and the
deadlock disappeared!
Thank you for your help
Olivier