Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.6, 2.5.2
-
None
-
Unknown
Description
org.apache.cxf.transport.http.finalizeConfig() calling two times client.addPropertyChangeListener(this) resulting in duplicated PropertyChangeListener entry in the HTTPClientPolicy.propertyListener field.
First instance added is here:
Thread [main] (Suspended (breakpoint at line 859 in org.apache.cxf.transport.http.HTTPConduit)) org.apache.cxf.transport.http.HTTPConduit.setClient(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) line: 859 org.apache.cxf.transport.http.HTTPConduit.configureConduitFromEndpointInfo(org.apache.cxf.transport.http.HTTPConduit, org.apache.cxf.service.model.EndpointInfo) line: 334 org.apache.cxf.transport.http.HTTPConduit.finalizeConfig() line: 413 org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(org.apache.cxf.service.model.EndpointInfo, org.apache.cxf.ws.addressing.EndpointReferenceType) line: 253
The second one is here:
Thread [main] (Suspended) org.apache.cxf.transport.http.HTTPConduit.finalizeConfig() line: 421 org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(org.apache.cxf.service.model.EndpointInfo, org.apache.cxf.ws.addressing.EndpointReferenceType) line: 253
This problem seem to had been introduced when we upgraded to version 2.5.2 from version 2.3.2
Because we implemented a custom ConduitSelector and reuse the Conduit instance, this generated a memory leak from HTTPClientPolicy.propertyListener.
The work around we currently use to clean the extra instances is by reflection.
We use reflection to know how much duplicate instances there is in HTTPClientPolicy.propertyListener because there is no public api to access the array.
We then call HTTPClientPolicy.removePropertyChangeListener(listener) multiple time with the same instance to remove all of them as in the following snipplet from our implementation of ConduitSelector.complete() :
PropertyChangeListener listener = (PropertyChangeListener) selectedConduit; List<HTTPClientPolicy> policies = pExchange.getEndpoint().getEndpointInfo().getExtensors( HTTPClientPolicy.class); for (HTTPClientPolicy policy : policies) { long nbListener = CxfReflectionInstrospectorUtil.getListenerNb(policy, listener); while (nbListener > 0) { policy.removePropertyChangeListener(listener); --nbListener; } }
regards and many thanks for your efforts,
Louis-Rene Poirier Beauchemin.