Android2.3系でDNSキャッシュをクリアする

http://qiita.com/kacchan6@github/items/4b2165c5cd20b3c54d2f

DNSレコードのTTLが何故か無視されている

うう。
これかな。
Issue 7904: Android does not support TTL and caches DNS result for 10 minutes
https://code.google.com/p/android/issues/detail?id=7904
libcore/luni/src/main/java/java/net/InetAddress.java

122 *

On Android, addresses are cached for 600 seconds (10 minutes) by default. Failed lookups are
123 * cached for 10 seconds. The underlying C library or OS may cache for longer, but you can control
124 * the Java-level caching with the usual {@code "networkaddress.cache.ttl"} and
125 * {@code "networkaddress.cache.negative.ttl"} system properties. These are parsed as integer
126 * numbers of seconds, where the special value 0 means "don't cache" and -1 means "cache forever".

DEFAULT_NETADDR_CACHE_TTL_SECSなんて、2.3にはないっすね...
http://tools.oesf.biz/android-4.0.1_r1.0/xref/libcore/luni/src/main/java/java/net/InetAddress.java
4.0にもないわ。


あったあった。
http://tools.oesf.biz/android-2.3.7_r1.0/xref/libcore/luni/src/main/java/java/net/AddressCache.java

38 // Default time-to-live for positive cache entries. 600 seconds (10 minutes).
39 private static final long DEFAULT_POSITIVE_TTL_NANOS = 600 * 1000000000L;
40 // Default time-to-live for negative cache entries. 10 seconds.
41 private static final long DEFAULT_NEGATIVE_TTL_NANOS = 10 * 1000000000L;


これで修正。でもJBへのパッチ。
https://android.googlesource.com/platform/libcore/+/afd70b773bd938c845a3bb0d9a3e21ec64d4db1a