felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@gmail.com>
Subject Re: Intermittent exception during Felix shutdown
Date Wed, 22 Aug 2007 15:41:25 GMT
Hi Rajini,

I have to admit, that I am not 100% sure, what is going on. But this is
what I suppose:

Some component has to be activated resulting thus (probably) calling the
ImmediateComponentManager.createObjectInstance method (most probably
asynchronously). Most probably this fails and results in the
AbstractComponentManager.deactivate() method being called. This method
(asynchronously again, but actually queued, so definitively later) tries
to unregister a service which may or may not be registered...

At the "same time" (whatever that means :-) ) the Bundle containing the
component is being stopped (probably due to framework shutdown, doesn't
matter, actually)  and the framework has already unregistered the
service.

The problem here is, that the createObjectInstance method should not
call the deactivate method for asynchronous deactivation. In fact, no
real deactivation is needed anyway, so I rewrote that part of the
implementation.

I will test this code with my tests further. Could you also test your
testcase again ? Thanks. I did not deploy a new snapshot yet, so you
will have to build it yourself. If this is not possible for you, please
let me know.

Regards
Felix

Am Montag, den 20.08.2007, 15:18 +0100 schrieb Rajini Sivaram:
> Hello,
> 
> One of my testcases intermittently throws an exception during shutdown. I
> have managed to recreate the exception under a debugger, and it shows two
> threads trying to unregister the same service. The test fails only when
> declarative services are used. I am using Felix 1.0.0. The test uses
> multiple versions of a bundle, but I am not sure if that has anything to do
> with the exception.
> 
> The exception thrown is:
> 
>     --- Exception with component : Unexpected problem executing task ---
>     java.lang.IllegalStateException: Service already unregistered.
>         at org.apache.felix.framework.ServiceRegistrationImpl.unregister(
> ServiceRegistrationImpl.java:105)
>         at
> org.apache.felix.scr.AbstractComponentManager.unregisterComponentService(
> AbstractComponentManager.java:503)
>         at org.apache.felix.scr.AbstractComponentManager.deactivateInternal(
> AbstractComponentManager.java:369)
>         at org.apache.felix.scr.AbstractComponentManager.access$200(
> AbstractComponentManager.java:55)
>         at org.apache.felix.scr.AbstractComponentManager$3.run(
> AbstractComponentManager.java:176)
>         at org.apache.felix.scr.ComponentActorThread.run(
> ComponentActorThread.java:81)
> 
> Here is the stack trace of the two threads under the debugger (both are
> using the same object):
> 
>                 Thread [FelixStartLevel] (Suspended (breakpoint at line 97
> in ServiceRegistrationImpl))
>                         ServiceRegistrationImpl.unregister() line: 97
>                         ServiceRegistry.unregisterServices(Bundle) line: 119
>                         Felix._stopBundle(FelixBundle, boolean) line: 1946
>                         Felix.stopBundle(FelixBundle, boolean) line: 1866
>                         Felix.setFrameworkStartLevel(int) line: 1080
>                         StartLevelImpl.run() line: 258
>                         Thread.run() line: 803
>                 Thread [SCR Component Actor] (Suspended (breakpoint at line
> 97 in ServiceRegistrationImpl))
>                         ServiceRegistrationImpl.unregister() line: 97
> 
> ImmediateComponentManager(AbstractComponentManager).unregisterComponentService()
> line: 503
> 
> ImmediateComponentManager(AbstractComponentManager).deactivateInternal()
> line: 369
> 
> AbstractComponentManager.access$200(AbstractComponentManager)
> line: 55
>                         AbstractComponentManager$3.run() line: 176
>                         ComponentActorThread.run() line: 81
> 
> 
> The exception thrown is the IllegalStateException from
>     public void unregister()
>     {
>         if (m_svcObj != null)
>         {
>             m_registry.unregisterService(m_bundle, this);
>             m_svcObj = null;
>             m_factory = null;
>         }
>         else
>         {
>            * throw new IllegalStateException("Service already
> unregistered.");
> *        }
>     }
> 
> 
> 
> Thank you...
> 
> Regards,
> 
> Rajini


Mime
View raw message