[ 
https://issues.apache.org/jira/browse/CXF-4131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Kulp resolved CXF-4131.
------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: NeedMoreInfo)
                   2.5.3
                   2.4.7
         Assignee: Daniel Kulp
    
> org.apache.cxf.transport.http.finalizeConfig()  duplicate property listener 
> and possible memory leak
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CXF-4131
>                 URL: https://issues.apache.org/jira/browse/CXF-4131
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.4.6, 2.5.2
>            Reporter: Louis-Rene Poirier Beauchemin
>            Assignee: Daniel Kulp
>             Fix For: 2.4.7, 2.5.3
>
>
> 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:
> {noformat} 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     
> {noformat} 
> The second one is here:
> {noformat} 
> 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 
> {noformat} 
> 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() :
> {noformat} 
>  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;
>                             }
>                         }
> {noformat} 
> regards and many thanks for your efforts,
> Louis-Rene Poirier Beauchemin.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to