cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrea Silva (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-6062) Interceptors added in Spring Bus configuration are ignored
Date Fri, 24 Oct 2014 08:20:33 GMT
Andrea Silva created CXF-6062:
---------------------------------

             Summary: Interceptors added in Spring Bus configuration are ignored 
                 Key: CXF-6062
                 URL: https://issues.apache.org/jira/browse/CXF-6062
             Project: CXF
          Issue Type: Bug
          Components: Bus
    Affects Versions: 3.0.2
            Reporter: Andrea Silva
            Priority: Critical


Given a basic spring bus configuration like the following:

{code}
...
<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
 
    <cxf:bus>
        <cxf:inInterceptors>
            <ref bean="logInbound"/>
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outFaultInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="logInbound"/>
        </cxf:inFaultInterceptors>
    </cxf:bus> 
...
{code} 

the logInbound and logOutbound interceptors are not added to the bus, when the spring configuration
is parsed.

I think the problem is in BusDefinitionParser.java, more specifically in the setBus method
of BusConfig class.

{code}
public void setBus(Bus bb) {
    if (bus == bb) {
        return;
    }
    bus = bb;
    if (properties != null) {
        bus.setProperties(properties);
        properties = null;
    }
    if (!getInInterceptors().isEmpty()) {
        bus.getInInterceptors().addAll(getInInterceptors());
    }
    if (!getOutInterceptors().isEmpty()) {
        bus.getOutInterceptors().addAll(getOutInterceptors());
    }
    if (!getInFaultInterceptors().isEmpty()) {
        bus.getInFaultInterceptors().addAll(getInFaultInterceptors());
    }
    if (!getOutFaultInterceptors().isEmpty()) {
        bus.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
    }
    if (!StringUtils.isEmpty(id)) {
        bus.setId(id);
    }
    if (features != null) {
        bus.setFeatures(features);
        features = null;
    }
}
{code}

If the bus is assigned at the beginning of the method (bus = bb;) no new Interceptor will
be added as the getXYZInterceptors methods will return the interceptors already included in
the bus.

{code}
public List<Interceptor<? extends Message>> getXYZInterceptors() {
            if (bus != null) {
                return bus.getXYZInterceptors();
            }
            return super.getXYZInterceptors();
}
{code}

A fix could be something along the line of:

{code}
public void setBus(Bus bb) {
    if (bus == bb) {
        return;
    }
    CXFBusImpl b = (CXFBusImpl)bb;
    if (properties != null) {
        b.setProperties(properties);
        properties = null;
    }
    if (!getInInterceptors().isEmpty()) {
        b.getInInterceptors().addAll(getInInterceptors());
    }
    if (!getOutInterceptors().isEmpty()) {
        b.getOutInterceptors().addAll(getOutInterceptors());
    }
    if (!getInFaultInterceptors().isEmpty()) {
        b.getInFaultInterceptors().addAll(getInFaultInterceptors());
    }
    if (!getOutFaultInterceptors().isEmpty()) {
        b.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
    }
    if (!StringUtils.isEmpty(id)) {
        b.setId(id);
    }
    if (features != null) {
        b.setFeatures(features);
        features = null;
    }
    bus = b;
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message