Skip to content
Permalink
Browse files
[CXF-8702] If the Spring application context is creating the bus and …
…has the shutdown method already wired, don't call shutdown when the application context is closed as that may interfere with other close events.
  • Loading branch information
dkulp committed May 10, 2022
1 parent 940e4ee commit 2b3ec63eb1c71f9dc58cff5e6244a2dfa356340e
Showing 2 changed files with 15 additions and 2 deletions.
@@ -40,9 +40,18 @@ public class SpringBus extends ExtensionManagerBus

AbstractApplicationContext ctx;
boolean closeContext;
boolean contextLifecycleManaged;

public SpringBus() {
}

public SpringBus(boolean ctxManaged) {
// if this Bus is created via the cxf.xml, then the spring context has the "shutdown" method
// already configured as a destroy method. Thus, we should NOT call destroy
// when the context is closed as Spring will do so the rest of the dependencies
// and such are ready to be destroyed.
contextLifecycleManaged = ctxManaged;
}

public void setBusConfig(BusDefinitionParser.BusConfig bc) {
bc.setBus(this);
@@ -102,7 +111,9 @@ public void onApplicationEvent(ApplicationEvent event) {
if (getState() != BusState.RUNNING) {
initialize();
}
} else if (event instanceof ContextClosedEvent && getState() == BusState.RUNNING) {
} else if (event instanceof ContextClosedEvent
&& getState() == BusState.RUNNING
&& (!contextLifecycleManaged || ctx instanceof BusApplicationContext)) {
// The bus could be create by using SpringBusFactory.createBus("/cxf.xml");
// Just to make sure the shutdown is called rightly
shutdown();
@@ -26,7 +26,9 @@
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/>
<context:annotation-config/>
-->
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus" destroy-method="shutdown"/>
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus" destroy-method="shutdown">
<constructor-arg type="boolean" value="true" />
</bean>
<bean id="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor" class="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor" class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.BusExtensionPostProcessor" class="org.apache.cxf.bus.spring.BusExtensionPostProcessor"/>

0 comments on commit 2b3ec63

Please sign in to comment.