Author: veithen Date: Sun Jul 4 12:53:06 2010 New Revision: 960335 URL: http://svn.apache.org/viewvc?rev=960335&view=rev Log: Reverted r958718 (related to AXIS2-4751) because this change causes a regression in Rampart.
Modified: axis/axis2/java/core/branches/java/1_5/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Modified: axis/axis2/java/core/branches/java/1_5/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/java/1_5/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?rev=960335&r1=960334&r2=960335&view=diff ============================================================================== --- axis/axis2/java/core/branches/java/1_5/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original) +++ axis/axis2/java/core/branches/java/1_5/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Sun Jul 4 12:53:06 2010 @@ -479,53 +479,35 @@ public abstract class AbstractHTTPSender } protected HttpClient getHttpClient(MessageContext msgContext) { - ConfigurationContext configContext = msgContext.getConfigurationContext(); - - HttpClient httpClient = (HttpClient) msgContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT); - if (httpClient == null) { + HttpClient httpClient; + final ConfigurationContext configContext = msgContext.getConfigurationContext(); + synchronized (lock) { httpClient = (HttpClient) configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT); - } - if (httpClient != null) { - return httpClient; - } - - HttpConnectionManager connManager = - (HttpConnectionManager) msgContext.getProperty( - HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER); - if (connManager == null) { - connManager = - (HttpConnectionManager) msgContext.getProperty( - HTTPConstants.MUTTITHREAD_HTTP_CONNECTION_MANAGER); - } - if (connManager == null) { - // reuse HttpConnectionManager - synchronized (configContext) { - connManager = (HttpConnectionManager) configContext.getProperty( - HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER); - if (connManager == null) { - log.trace("Making new ConnectionManager"); - connManager = new MultiThreadedHttpConnectionManager(); - configContext.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, - connManager); - } + if (httpClient == null) { + log.trace("Making new ConnectionManager"); + HttpConnectionManager connManager = new MultiThreadedHttpConnectionManager(); + + // In case we need to set any params, do it here, but for now use defaults. +// HttpConnectionManagerParams params = new HttpConnectionManagerParams(); +// params.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 200); +// etc... +// connManager.setParams(params); + + httpClient = new HttpClient(connManager); + HttpClientParams clientParams = new HttpClientParams(); + // Set the default timeout in case we have a connection pool starvation to 30sec + clientParams.setConnectionManagerTimeout(30000); + httpClient.setParams(clientParams); + configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); } - } - - /* - * Create a new instance of HttpClient since the way - * it is used here it's not fully thread-safe. - */ - httpClient = new HttpClient(connManager); - - // Set the default timeout in case we have a connection pool starvation to 30sec - httpClient.getParams().setConnectionManagerTimeout(30000); - - // Get the timeout values set in the runtime - initializeTimeouts(msgContext, httpClient); + // Get the timeout values set in the runtime + initializeTimeouts(msgContext, httpClient); + } return httpClient; } + static final Object lock = new Object(); protected void executeMethod(HttpClient httpClient, MessageContext msgContext, URL url, HttpMethod method) throws IOException { HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);