ProviderProcessor leaks memory for https endpoints
--------------------------------------------------

                 Key: SM-928
                 URL: https://issues.apache.org/activemq/browse/SM-928
             Project: ServiceMix
          Issue Type: Bug
          Components: servicemix-http
    Affects Versions: 3.1
            Reporter: Dejan Predovic


ProviderProcessor creates a new CommonsHttpSSLSocketFactory/Protocol instance 
for each message. These instances are in turn used as a part of HttpHost 
equals/hashCode identity. HttpHost instances are internally cached by 
MultiThreadedHttpConnectionManager and having new CommonsHttpSSLSocketFactory 
creates a new cache instance for every call.

Making Protocol an instance variable and changing:

{code}
   if (uri.getScheme().equals("https")) {
            ProtocolSocketFactory sf = new CommonsHttpSSLSocketFactory(
                            endpoint.getSsl(),
                            endpoint.getKeystoreManager());
            Protocol protocol = new Protocol("https", sf, 443);
            HttpHost httphost = new HttpHost(uri.getHost(), uri.getPort(), 
protocol);
            host = new HostConfiguration();
            host.setHost(httphost);
        } else {
{code}

to:
{code}        
        if (uri.getScheme().equals("https")) {
            synchronized (this) {
                if (protocol == null) {
                    ProtocolSocketFactory sf = new CommonsHttpSSLSocketFactory(
                            endpoint.getSsl(),
                            endpoint.getKeystoreManager());
                    protocol = new Protocol("https", sf, 443);
                }
            }
            HttpHost httphost = new HttpHost(uri.getHost(), uri.getPort(), 
protocol);
            host = new HostConfiguration();
            host.setHost(httphost);
        } else {
{code}

seems to work.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to