changeset 4511:0890350cf539

7022407: Spinning CPU in LocaleObjectCache.get() Reviewed-by: okutsu
author naoto
date Tue, 22 Nov 2011 11:29:03 -0800
parents f1d09dc7f9a7
children f604183d865f b97711a21785
files src/share/classes/sun/util/locale/LocaleObjectCache.java
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/util/locale/LocaleObjectCache.java	Fri Nov 11 15:17:51 2011 +0300
+++ b/src/share/classes/sun/util/locale/LocaleObjectCache.java	Tue Nov 22 11:29:03 2011 -0800
@@ -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();
                 }
             }
         }