[ 
https://issues.apache.org/jira/browse/FELIX-971?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard S. Hall resolved FELIX-971.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: felix-1.6.0
         Assignee: Richard S. Hall

After thinking about this some more, I decided to move bundle context 
invalidation after all bundle shutdown tasks. The reason I decided to do this, 
is because there is no way we can guarantee a bundle cannot receive events 
between the time its BundleActivator.stop() method returns and until we 
invalidate its context, so it makes sense to keep the context valid until the 
bundle can no longer receive events.

Further, the spec can be interpreted this way, since it says the context should 
be valid while the bundle is STARTING, ACTIVE, and STOPPING. A bundle is 
STOPPING during all of the bundle shutdown tasks, so this implies the context 
should be valid during this.

Guillaume, could you see if your example works with out exceptions now? If so, 
please close this issue. Thanks.

> Exception thrown in ServiceTracker at shutdown 
> -----------------------------------------------
>
>                 Key: FELIX-971
>                 URL: https://issues.apache.org/jira/browse/FELIX-971
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>            Reporter: Guillaume Nodet
>            Assignee: Richard S. Hall
>            Priority: Minor
>             Fix For: felix-1.6.0
>
>
> ERROR: EventDispatcher: Error during dispatch. 
> (java.lang.IllegalStateException: Invalid BundleContext.)
> java.lang.IllegalStateException: Invalid BundleContext.
>       at 
> org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:393)
>       at 
> org.apache.felix.framework.BundleContextImpl.ungetService(BundleContextImpl.java:362)
>       at 
> org.osgi.util.tracker.ServiceTracker.removedService(ServiceTracker.java:429)
>       at 
> org.osgi.util.tracker.ServiceTracker$Tracked.untrack(ServiceTracker.java:1126)
>       at 
> org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:957)
>       at 
> org.apache.felix.framework.util.EventDispatcher$4.run(EventDispatcher.java:812)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at 
> org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:809)
>       at 
> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:678)
>       at 
> org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:609)
>       at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3379)
>       at org.apache.felix.framework.Felix.access$000(Felix.java:39)
>       at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:620)
>       at 
> org.apache.felix.framework.ServiceRegistry.fireServiceChanged(ServiceRegistry.java:571)
>       at 
> org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:105)
>       at 
> org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:120)
>       at 
> org.apache.felix.framework.ServiceRegistry.unregisterServices(ServiceRegistry.java:146)
>       at org.apache.felix.framework.Felix.stopBundle(Felix.java:1815)
>       at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:999)
>       at 
> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>       at java.lang.Thread.run(Thread.java:613)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to