summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2015-08-13 17:02:24 -0700
committerSteve Kondik <steve@cyngn.com>2015-11-07 16:48:04 -0800
commiteaea8131f5dd68e346bd65334bd6aa14595d41e4 (patch)
tree12d6ba1cc5e334896982ece02c3d5bc76b7f0130 /luni
parenta9ba677f4fe48fbb3c6787129b75a3191decddcb (diff)
downloadlibcore-eaea8131f5dd68e346bd65334bd6aa14595d41e4.zip
libcore-eaea8131f5dd68e346bd65334bd6aa14595d41e4.tar.gz
libcore-eaea8131f5dd68e346bd65334bd6aa14595d41e4.tar.bz2
libcore: add a way to clear cached time zone strings
Ref: CYNGNOS-453 Change-Id: I5aaf315f0d2b7b039cacb5de135501cea4f7cf0c Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/libcore/icu/TimeZoneNames.java12
-rw-r--r--luni/src/main/java/libcore/util/BasicLruCache.java7
2 files changed, 19 insertions, 0 deletions
diff --git a/luni/src/main/java/libcore/icu/TimeZoneNames.java b/luni/src/main/java/libcore/icu/TimeZoneNames.java
index 3413a5d..139ab57 100644
--- a/luni/src/main/java/libcore/icu/TimeZoneNames.java
+++ b/luni/src/main/java/libcore/icu/TimeZoneNames.java
@@ -135,6 +135,18 @@ public final class TimeZoneNames {
}
/**
+ * Clear the cached zone strings for {@link Locale#getDefault()}.
+ * Does nothing if it returns {@link Locale#US} or {@link Locale#ROOT}.
+ */
+ public static void clearLocaleCache() {
+ Locale locale = Locale.getDefault();
+ if (locale.equals(Locale.US) || locale.equals(Locale.ROOT)) {
+ return;
+ }
+ cachedZoneStrings.remove(locale);
+ }
+
+ /**
* Returns an array containing the time zone ids in use in the country corresponding to
* the given locale. This is not necessary for Java API, but is used by telephony as a
* fallback. We retrieve these strings from zone.tab rather than icu4c because the latter
diff --git a/luni/src/main/java/libcore/util/BasicLruCache.java b/luni/src/main/java/libcore/util/BasicLruCache.java
index 75e4a75..00afa98 100644
--- a/luni/src/main/java/libcore/util/BasicLruCache.java
+++ b/luni/src/main/java/libcore/util/BasicLruCache.java
@@ -79,6 +79,13 @@ public class BasicLruCache<K, V> {
return previous;
}
+ public synchronized final V remove(K key) {
+ if (key == null) {
+ throw new NullPointerException("key == null");
+ }
+ return map.remove(key);
+ }
+
private void trimToSize(int maxSize) {
while (map.size() > maxSize) {
Map.Entry<K, V> toEvict = map.eldest();