Disable dnsjava hosts file parsing to fix NPE race condition.

This commit is contained in:
Greyson Parrelli
2026-05-19 23:51:39 +00:00
parent daec317f52
commit e750b81a31
@@ -56,7 +56,11 @@ public class CustomDns implements Dns {
private static @NonNull Lookup doLookup(@NonNull String hostname) throws UnknownHostException {
try {
return new Lookup(hostname);
Lookup lookup = new Lookup(hostname);
// Disable hosts file lookups to work around a race condition in dnsjava 3.6.4's that leads to an NPE.
// Android doesn't have a meaningful /etc/hosts anyway.
lookup.setHostsFileParser(null);
return lookup;
} catch (Throwable e) {
Log.w(TAG, e);
throw new UnknownHostException();