use ConcurrentHashMap rather than synchronized block

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235558 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-01-24 23:42:05 +00:00
parent 92e0de2ef1
commit 5eed5ccf55
1 changed files with 72 additions and 79 deletions

View File

@ -79,6 +79,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
/**
* DefaultRepositoryProxyConnectors
@ -140,7 +141,7 @@ public class DefaultRepositoryProxyConnectors
private Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<String, List<ProxyConnector>>();
private Map<String, ProxyInfo> networkProxyMap = new HashMap<String, ProxyInfo>();
private Map<String, ProxyInfo> networkProxyMap = new ConcurrentHashMap<String, ProxyInfo>();
/**
*
@ -168,13 +169,11 @@ public class DefaultRepositoryProxyConnectors
@SuppressWarnings( "unchecked" )
private void initConnectorsAndNetworkProxies()
{
synchronized ( this.proxyConnectorMap )
{
ProxyConnectorOrderComparator proxyOrderSorter = new ProxyConnectorOrderComparator();
this.proxyConnectorMap.clear();
List<ProxyConnectorConfiguration> proxyConfigs =
archivaConfiguration.getConfiguration().getProxyConnectors();
List<ProxyConnectorConfiguration> proxyConfigs = archivaConfiguration.getConfiguration().getProxyConnectors();
for ( ProxyConnectorConfiguration proxyConfig : proxyConfigs )
{
String key = proxyConfig.getSourceRepoId();
@ -235,16 +234,13 @@ public class DefaultRepositoryProxyConnectors
{
log.warn( "Unable to use proxy connector: " + e.getMessage(), e );
}
}
}
synchronized ( this.networkProxyMap )
{
this.networkProxyMap.clear();
List<NetworkProxyConfiguration> networkProxies =
archivaConfiguration.getConfiguration().getNetworkProxies();
List<NetworkProxyConfiguration> networkProxies = archivaConfiguration.getConfiguration().getNetworkProxies();
for ( NetworkProxyConfiguration networkProxyConfig : networkProxies )
{
String key = networkProxyConfig.getId();
@ -259,7 +255,7 @@ public class DefaultRepositoryProxyConnectors
this.networkProxyMap.put( key, proxy );
}
}
}
public File fetchFromProxies( ManagedRepositoryContent repository, ArtifactReference artifact )
@ -1046,11 +1042,8 @@ public class DefaultRepositoryProxyConnectors
{
boolean connected = false;
final ProxyInfo networkProxy;
synchronized ( this.networkProxyMap )
{
networkProxy = (ProxyInfo) this.networkProxyMap.get( connector.getProxyId() );
}
final ProxyInfo networkProxy = this.networkProxyMap.get( connector.getProxyId() );
if ( log.isDebugEnabled() )
{