This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new f8b5882  CAMEL-11876: On shutdown of camel-core-osgi then unregister 
any leftover CamelContext which was supposed to be unregistered by somehow was 
not.
f8b5882 is described below

commit f8b5882cf402dc4c6f78c6fde6ca53e519032163
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Thu Feb 1 15:43:10 2018 +0100

    CAMEL-11876: On shutdown of camel-core-osgi then unregister any leftover 
CamelContext which was supposed to be unregistered by somehow was not.
---
 .../camel/core/osgi/OsgiCamelContextPublisher.java      | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java
 
b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java
index 8c7ed85..307a12b 100644
--- 
a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java
+++ 
b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java
@@ -67,7 +67,7 @@ public class OsgiCamelContextPublisher extends 
EventNotifierSupport {
                 try {
                     reg.unregister();
                 } catch (Exception e) {
-                    log.warn("Error unregistering CamelContext [{}] from OSGi 
registry. This exception will be ignored.", context.getName(), e);
+                    log.warn("Error unregistering CamelContext [" + 
context.getName() + "] from OSGi registry. This exception will be ignored.", e);
                 }
             }
         }
@@ -90,6 +90,17 @@ public class OsgiCamelContextPublisher extends 
EventNotifierSupport {
 
     @Override
     protected void doShutdown() throws Exception {
+        // clear and unregister any left-over registration (which should not 
happen)
+        if (!registrations.isEmpty()) {
+            log.warn("On shutdown there are {} registrations which was 
supposed to have been unregistered already. Will unregister these now.", 
registrations.size());
+            for (ServiceRegistration<?> reg : registrations.values()) {
+                try {
+                    reg.unregister();
+                } catch (Exception e) {
+                    log.warn("Error unregistering from OSGi registry. This 
exception will be ignored.", e);
+                }
+            }
+        }
         registrations.clear();
     }
 
@@ -112,9 +123,7 @@ public class OsgiCamelContextPublisher extends 
EventNotifierSupport {
                 props.put(CONTEXT_MANAGEMENT_NAME_PROPERTY, managementName);
             }
 
-            if (log.isDebugEnabled()) {
-                log.debug("Registering CamelContext [{}] of in OSGi registry", 
name);
-            }
+            log.debug("Registering CamelContext [{}] in OSGi registry", name);
 
             ServiceRegistration<?> reg = 
bundleContext.registerService(CamelContext.class.getName(), camelContext, 
props);
             if (reg != null) {

-- 
To stop receiving notification emails like this one, please contact
davscl...@apache.org.

Reply via email to