From d5d5914de51506e0f1a2e182c1209b78681178b6 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sat, 27 Feb 2010 12:10:19 +0000 Subject: [PATCH] Replaced synchronized HashMap with ConcurrentHashMap git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@916946 13f79535-47bb-0310-9956-ffa450edef68 --- .../impl/client/BasicCredentialsProvider.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java index b611f04bc..d6be0e2eb 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java @@ -26,9 +26,9 @@ package org.apache.http.impl.client; -import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; -import org.apache.http.annotation.GuardedBy; import org.apache.http.annotation.ThreadSafe; import org.apache.http.auth.AuthScope; @@ -43,18 +43,17 @@ import org.apache.http.client.CredentialsProvider; @ThreadSafe public class BasicCredentialsProvider implements CredentialsProvider { - @GuardedBy("this") - private final HashMap credMap; + private final ConcurrentHashMap credMap; /** * Default constructor. */ public BasicCredentialsProvider() { super(); - this.credMap = new HashMap(); + this.credMap = new ConcurrentHashMap(); } - public synchronized void setCredentials( + public void setCredentials( final AuthScope authscope, final Credentials credentials) { if (authscope == null) { @@ -72,7 +71,7 @@ public class BasicCredentialsProvider implements CredentialsProvider { * */ private static Credentials matchCredentials( - final HashMap map, + final Map map, final AuthScope authscope) { // see if we get a direct hit Credentials creds = map.get(authscope); @@ -95,14 +94,14 @@ public class BasicCredentialsProvider implements CredentialsProvider { return creds; } - public synchronized Credentials getCredentials(final AuthScope authscope) { + public Credentials getCredentials(final AuthScope authscope) { if (authscope == null) { throw new IllegalArgumentException("Authentication scope may not be null"); } return matchCredentials(this.credMap, authscope); } - public synchronized void clear() { + public void clear() { this.credMap.clear(); }