hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r916946 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
Date Sat, 27 Feb 2010 12:10:20 GMT
Author: olegk
Date: Sat Feb 27 12:10:19 2010
New Revision: 916946

URL: http://svn.apache.org/viewvc?rev=916946&view=rev
Log:
Replaced synchronized HashMap with ConcurrentHashMap

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java?rev=916946&r1=916945&r2=916946&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
Sat Feb 27 12:10:19 2010
@@ -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 @@
 @ThreadSafe
 public class BasicCredentialsProvider implements CredentialsProvider {
 
-    @GuardedBy("this")
-    private final HashMap<AuthScope, Credentials> credMap;
+    private final ConcurrentHashMap<AuthScope, Credentials> credMap;
 
     /**
      * Default constructor.
      */
     public BasicCredentialsProvider() {
         super();
-        this.credMap = new HashMap<AuthScope, Credentials>();
+        this.credMap = new ConcurrentHashMap<AuthScope, Credentials>();
     }
 
-    public synchronized void setCredentials(
+    public void setCredentials(
             final AuthScope authscope, 
             final Credentials credentials) {
         if (authscope == null) {
@@ -72,7 +71,7 @@
      * 
      */
     private static Credentials matchCredentials(
-            final HashMap<AuthScope, Credentials> map, 
+            final Map<AuthScope, Credentials> map, 
             final AuthScope authscope) {
         // see if we get a direct hit
         Credentials creds = map.get(authscope);
@@ -95,14 +94,14 @@
         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();
     }
     



Mime
View raw message