I just tested blueprint-core with Guillaumes most recent commit on current karaf-trunk and during shutdown I now get two Exceptions (see attachement). It only occurs with felix (not with equinox).

The problem is that the BlueprintExtender's stop-method is called twice. Once by the BundleTracker picks up the system-bundle stopping, and once again when the Framework call's it because it stops the bundle.

This means that the BundleHookBundleTracker's close-method is called twice. Doing this (as opposed to a regular BundleTracker) always results in a IllegalStateException (I filed ARIES-1005 for that).

kind regards,
Christoph

Author: gnodet
Date: Fri Jan 18 08:31:42 2013
New Revision: 1435050

URL: http://svn.apache.org/viewvc?rev=1435050&view=rev
Log:
[ARIES-1004] When the framework is being shut down, blueprint bundles are not 
shut down orderly

Modified:
    
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java

Modified: 
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java?rev=1435050&r1=1435049&r2=1435050&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
(original)
+++ 
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
Fri Jan 18 08:31:42 2013
@@ -190,6 +190,16 @@ public class BlueprintExtender implement
     }

     public void modifiedBundle(Bundle bundle, BundleEvent event, Object 
object) {
+        // If the bundle being stopped is the system bundle,
+        // do an orderly shutdown of all blueprint contexts now
+        // so that service usage can actually be useful
+        if (bundle.getBundleId() == 0 && bundle.getState() == Bundle.STOPPING) 
{
+            String val = 
context.getProperty("org.apache.aries.blueprint.preemptiveShutdown");
+            if (val == null || Boolean.parseBoolean(val)) {
+                stop(context);
+                return;
+            }
+        }
         if (bundle.getState() != Bundle.ACTIVE && bundle.getState() != 
Bundle.STARTING)
{
             // The bundle is not in STARTING or ACTIVE state anymore
             // so destroy the context
ERROR: Bundle org.apache.aries.blueprint.core [5] Error stopping bundle. 
(java.lang.IllegalStateException: Service already unregistered.)
java.lang.IllegalStateException: Service already unregistered.
        at 
org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:123)
        at 
org.apache.aries.util.tracker.hook.BundleHookBundleTracker.close(BundleHookBundleTracker.java:88)
        at 
org.apache.aries.util.tracker.RecursiveBundleTracker.close(RecursiveBundleTracker.java:106)
        at 
org.apache.aries.blueprint.container.BlueprintExtender.stop(BlueprintExtender.java:160)
        at 
org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:667)
        at org.apache.felix.framework.Felix.stopBundle(Felix.java:2361)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1214)
        at 
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
        at java.lang.Thread.run(Thread.java:722)
ERROR: Bundle org.apache.aries.blueprint.core [5] Error stopping 
mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core/1.1.0-SUP-01 
(org.osgi.framework.BundleException: Activator stop error in bundle 
org.apache.aries.blueprint.core [5].)
java.lang.IllegalStateException: Service already unregistered.
        at 
org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:123)
        at 
org.apache.aries.util.tracker.hook.BundleHookBundleTracker.close(BundleHookBundleTracker.java:88)
        at 
org.apache.aries.util.tracker.RecursiveBundleTracker.close(RecursiveBundleTracker.java:106)
        at 
org.apache.aries.blueprint.container.BlueprintExtender.stop(BlueprintExtender.java:160)
        at 
org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:667)
        at org.apache.felix.framework.Felix.stopBundle(Felix.java:2361)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1214)
        at 
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
        at java.lang.Thread.run(Thread.java:722)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to