catch some more NPE in Resolver.java

This commit is contained in:
Christian Schneppe 2020-02-08 18:38:19 +01:00
parent 2d5a7e013a
commit e96467e5ad
No known key found for this signature in database
GPG key ID: F30B8D686B44D87E

View file

@ -6,6 +6,8 @@ import android.util.Log;
import androidx.annotation.NonNull;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.InetAddress;
@ -65,7 +67,9 @@ public class Resolver {
final Field dnsClientField = ReliableDNSClient.class.getDeclaredField("dnsClient");
dnsClientField.setAccessible(true);
final DNSClient dnsClient = (DNSClient) dnsClientField.get(reliableDNSClient);
dnsClient.getDataSource().setTimeout(3000);
if (dnsClient != null) {
dnsClient.getDataSource().setTimeout(3000);
}
final Field useHardcodedDnsServers = DNSClient.class.getDeclaredField("useHardcodedDnsServers");
useHardcodedDnsServers.setAccessible(true);
useHardcodedDnsServers.setBoolean(dnsClient, false);
@ -382,6 +386,7 @@ public class Resolver {
return socket;
}
@NotNull
@Override
public String toString() {
return "Result{" +