Federico Mariani created CAMEL-24181:
----------------------------------------
Summary: camel-cxf - CxfSpringEndpoint shuts down the shared
application-wide CXF bus on endpoint stop
Key: CAMEL-24181
URL: https://issues.apache.org/jira/browse/CAMEL-24181
Project: Camel
Issue Type: Bug
Components: camel-cxf
Reporter: Federico Mariani
Assignee: Federico Mariani
*Severity:* High
h3. Problem
{{CxfSpringEndpoint.setApplicationContext}} does:
{code:java}
if (bus == null) {
createBus = true;
bus = BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx);
}
{code}
{{addDefaultBus}} returns the *context-wide singleton* bus bean {{"cxf"}} -
creating it only if absent, otherwise returning the user's own bus
({{<cxf:bus>}}, imported {{cxf.xml}}). Setting {{createBus = true}} marks this
shared bus as endpoint-owned, so the inherited {{CxfEndpoint.doStop()}} runs
{{getBus().shutdown(false)}} on it. Every {{<cxf:cxfEndpoint>}} bean (prototype
scope) shares the one {{"cxf"}} bus.
h3. Impact
In a Spring context with more than one route using {{<cxf:cxfEndpoint>}} (or a
Camel route plus a non-Camel CXF {{<jaxws:endpoint>}} on the default bus),
removing/stopping one route while the application keeps running shuts down the
*application-wide* bus - every other CXF server/client on that bus stops
responding. Worse variant: the user explicitly configured {{<cxf:bus>}}; Camel
still sets {{createBus=true}} and destroys a user-managed bean.
h3. Location
{{components/camel-cxf/camel-cxf-spring-soap/src/main/java/org/apache/camel/component/cxf/spring/jaxws/CxfSpringEndpoint.java}}
~272-279, with {{CxfEndpoint.doStop()}}. Introduced by CAMEL-12829 (added
{{createBus = true}} to fix a leak, without considering the
shared/user-supplied bus case).
h3. Fix
Do not set {{createBus = true}} when the bus came from / already existed in the
application context - its lifecycle belongs to Spring ({{SpringBus}} shuts
itself down on {{ContextClosedEvent}}). Only claim ownership of a genuinely
auto-created bus (when {{ctx.containsBean("cxf")}} was false) and shut it down
on ApplicationContext close, not endpoint stop.
----
_Filed by Claude Code (Claude Fable) on behalf of Federico Mariani (GitHub:
Croway). Findings from an AI-assisted code review of the camel-cxf component
family; each item was verified against the current source and git history.
Items marked *[reproducer attached]* include a failing JUnit test that
demonstrates the defect._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)