If a user creates a basic application outside of spring but using Spring config 
and THEY manage the bus via a BusFactory, this MAY result in a loop at shutdown.

Bus bus = new SpringBusFactory.createBus(“/cxf.xml”);

.. do stuff with bus …

bus.shutdown();

Looking at the code for this, shutdown() would call destroyBeans() which would 
call ctx.close() which would trigger your ContextClosedEvent which would 
re-call shutdown…. 

The check:
if (state == BusState.SHUTTING_DOWN)…

SHOULD prevent any problems with that, but you’d definitely need to check to 
make sure.  That said, it shouldn’t be hard check, we do this type of thing in 
our system tests all over the place.


Dan





On Jan 20, 2014, at 7:43 AM, Willem Jiang <[email protected]> wrote:

> Hi,
> 
> I was tracing a CXFBus leak issue recently.
> 
> Here are the some details about the application bundle: 
> 
> It's Spring application context holds a camel context which has a camel-cxf 
> endpoint to receive the invocation from outside. When the application bundle 
> is uninstalled from Karaf, the SpringBus doesn’t shutdown itself and 
> CXFBusFactory doesn’t clean itself up.
> 
> If the application bundle is changed to use Blueprint to load the same Camel 
> context, we don’t find any Bus leak by dump the memory of the JVM.
> 
> I dig the SpringBus code and found it registers an ApplicationListener which 
> handles application context refresh and close event.
> 
> My patch is just replacing the 
> getExtension(BusLifeCycleManager.class).postShutdown(); with bus  shutdown(). 
> 
> --- a/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
> +++ b/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
> @@ -21,7 +21,7 @@ package org.apache.cxf.bus.spring;
>  
>  import org.apache.cxf.bus.BusState;
>  import org.apache.cxf.bus.extension.ExtensionManagerBus;
> -import org.apache.cxf.buslifecycle.BusLifeCycleManager;
>  import org.apache.cxf.configuration.ConfiguredBeanLocator;
>  import org.apache.cxf.configuration.Configurer;
>  import org.apache.cxf.configuration.spring.ConfigurerImpl;
> @@ -110,7 +110,8 @@ public class SpringBus extends ExtensionManagerBus
>                      initialize();
>                  }
>              } else if (event instanceof ContextClosedEvent) {
> -                getExtension(BusLifeCycleManager.class).postShutdown();
> +                shutdown();
>              }
>          }
>      }
> 
> Is there any thing that I'm missing?
> 
> --  
> Willem Jiang
> 
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) 
> (English)
> http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang  
> Weibo: 姜宁willem
> 
> 
> 

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to