changeset 4420:42fe05e54e69

7022407: Spinning CPU in LocaleObjectCache.get() Reviewed-by: okutsu
author naoto
date Tue, 12 Jul 2011 10:28:37 -0700
parents 549b7c3f0bdc
children db419c454f92
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	Tue Jul 12 15:23:23 2011 +0100
+++ b/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();
                 }
             }
         }