7022407: Spinning CPU in LocaleObjectCache.get()
authornaoto
Tue, 12 Jul 2011 10:28:37 -0700
changeset 10118 c22b087661be
parent 10117 a5f22ff57f3c
child 10119 277fd8d9fcda
7022407: Spinning CPU in LocaleObjectCache.get() Reviewed-by: okutsu
jdk/src/share/classes/sun/util/locale/LocaleObjectCache.java
--- a/jdk/src/share/classes/sun/util/locale/LocaleObjectCache.java	Tue Jul 12 15:23:23 2011 +0100
+++ b/jdk/src/share/classes/sun/util/locale/LocaleObjectCache.java	Tue Jul 12 10:28:37 2011 -0700
@@ -66,14 +66,14 @@
 
             CacheEntry<K, V> newEntry = new CacheEntry<>(key, newVal, queue);
 
-            while (value == null) {
-                cleanStaleEntries();
-                entry = map.putIfAbsent(key, newEntry);
-                if (entry == null) {
+            entry = map.putIfAbsent(key, newEntry);
+            if (entry == null) {
+                value = newVal;
+            } else {
+                value = entry.get();
+                if (value == null) {
+                    map.put(key, newEntry);
                     value = newVal;
-                    break;
-                } else {
-                    value = entry.get();
                 }
             }
         }