[BUGFIX] happy eyeball: concurrents resolve connect

This commit is contained in:
genofire 2020-02-08 08:54:19 +01:00
parent 5e0856ee69
commit 3df33228a8
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 8 additions and 3 deletions

View File

@ -64,7 +64,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);
@ -293,7 +295,7 @@ public class Resolver {
Log.e(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball failed: ", e);
return null;
} catch (ExecutionException e) {
Log.e(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball failed: ", e);
Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball unable to connect to one address");
return null;
}
}
@ -428,7 +430,10 @@ public class Resolver {
@Override
public Result call() throws Exception {
this.connect();
return this.socket.isConnected() ? this : null;
if (this.socket != null && this.socket.isConnected()) {
return this ;
}
throw new Exception("Resolver.Result was not possible to connect - should be catched by executor");
}
public ContentValues toContentValues() {