OSDN Git Service

Using proper key for removing object from the map.
authorJozef BABJAK <jozef.babjak@gmail.com>
Mon, 21 Feb 2011 14:44:06 +0000 (15:44 +0100)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 5 Aug 2011 08:10:04 +0000 (16:10 +0800)
Stored value was used for map removal instead of key. The error was
silently ignore, because remove() method accepts Object type argument
and siletly does nothing when no value identified by such key is
found. Now proper key is used for removal. i.e. the same as for lookup.

Change-Id: I3a61fc219385cd0e7bcd4a33cd6ca23be220efe3

core/java/android/net/http/CertificateValidatorCache.java

index 47661d5..a89f75c 100644 (file)
@@ -137,8 +137,8 @@ class CertificateValidatorCache {
 
         if (domain != null && domain.length() != 0) {
             if (secureHash != null && secureHash.length != 0) {
-                CacheEntry cacheEntry = (CacheEntry)mCacheMap.get(
-                    new Integer(mBigScrew ^ domain.hashCode()));
+                final Integer key = new Integer(mBigScrew ^ domain.hashCode());
+                CacheEntry cacheEntry = mCacheMap.get(key);
                 if (cacheEntry != null) {
                     if (!cacheEntry.expired()) {
                         rval = cacheEntry.has(domain, secureHash);
@@ -148,7 +148,7 @@ class CertificateValidatorCache {
                         }
                         // TODO: debug only!
                     } else {
-                        mCacheMap.remove(cacheEntry);
+                        mCacheMap.remove(key);
                     }
                 }
             }