]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - jars/icu4j-52_1/main/classes/core/src/com/ibm/icu/impl/SoftCache.java
Upgrade ICU4J.
[Dictionary.git] / jars / icu4j-52_1 / main / classes / core / src / com / ibm / icu / impl / SoftCache.java
similarity index 93%
rename from jars/icu4j-4_8_1_1/main/classes/core/src/com/ibm/icu/impl/SoftCache.java
rename to jars/icu4j-52_1/main/classes/core/src/com/ibm/icu/impl/SoftCache.java
index dac71c6c1e0605bd7b7b86f113744aade9c005d9..e77f86cf2a0cacb8902406d152de75b7e0168e73 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2010, International Business Machines
+*   Copyright (C) 2010-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 */
@@ -46,13 +46,19 @@ public abstract class SoftCache<K, V, D> extends CacheBase<K, V, D> {
                 } else {
                     // The instance has been evicted, its SoftReference cleared.
                     // Create and set a new instance.
-                    valueRef.ref = new SoftReference<V>(value = createInstance(key, data));
+                    value = createInstance(key, data);
+                    if (value != null) {
+                        valueRef.ref = new SoftReference<V>(value);
+                    }
                     return value;
                 }
             }
         } else /* valueRef == null */ {
             // We had never cached an instance for this key.
             value = createInstance(key, data);
+            if (value == null) {
+                return null;
+            }
             valueRef = map.putIfAbsent(key, new SettableSoftReference<V>(value));
             if(valueRef == null) {
                 // Normal "put": Our new value is now cached.