[ https://issues.apache.org/jira/browse/CXF-6062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp resolved CXF-6062. ------------------------------ Resolution: Fixed Fix Version/s: 3.0.3 Assignee: Daniel Kulp > 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 > Assignee: Daniel Kulp > Priority: Critical > Fix For: 3.0.3 > > > 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; > } > > if (properties != null) { > bb.setProperties(properties); > properties = null; > } > if (!getInInterceptors().isEmpty()) { > bb.getInInterceptors().addAll(getInInterceptors()); > } > if (!getOutInterceptors().isEmpty()) { > bb.getOutInterceptors().addAll(getOutInterceptors()); > } > if (!getInFaultInterceptors().isEmpty()) { > bb.getInFaultInterceptors().addAll(getInFaultInterceptors()); > } > if (!getOutFaultInterceptors().isEmpty()) { > bb.getOutFaultInterceptors().addAll(getOutFaultInterceptors()); > } > if (!StringUtils.isEmpty(id)) { > bb.setId(id); > } > if (features != null) { > bb.setFeatures(features); > features = null; > } > bus = bb; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)