summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--luni/src/main/java/java/net/NetworkInterface.java7
-rw-r--r--luni/src/main/java/libcore/icu/TimeZoneNames.java12
-rw-r--r--luni/src/main/java/libcore/util/BasicLruCache.java7
3 files changed, 25 insertions, 1 deletions
diff --git a/luni/src/main/java/java/net/NetworkInterface.java b/luni/src/main/java/java/net/NetworkInterface.java
index 852c09b..0f8e37a 100644
--- a/luni/src/main/java/java/net/NetworkInterface.java
+++ b/luni/src/main/java/java/net/NetworkInterface.java
@@ -118,7 +118,12 @@ public final class NetworkInterface extends Object {
*/
private static NetworkInterface getByNameInternal(String interfaceName,
String[] ifInet6Lines) throws SocketException {
- int interfaceIndex = readIntFile("/sys/class/net/" + interfaceName + "/ifindex");
+ int interfaceIndex;
+ try {
+ interfaceIndex = readIntFile("/sys/class/net/" + interfaceName + "/ifindex");
+ } catch (SocketException e) {
+ return null;
+ }
List<InetAddress> addresses = new ArrayList<InetAddress>();
List<InterfaceAddress> interfaceAddresses = new ArrayList<InterfaceAddress>();
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();