From 3df33228a8ce573ecd6574be5aa982a64531bf51 Mon Sep 17 00:00:00 2001 From: genofire Date: Sat, 8 Feb 2020 08:54:19 +0100 Subject: [PATCH] [BUGFIX] happy eyeball: concurrents resolve connect --- .../java/eu/siacs/conversations/utils/Resolver.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/Resolver.java b/src/main/java/eu/siacs/conversations/utils/Resolver.java index 09f9c9612..e75843f2a 100644 --- a/src/main/java/eu/siacs/conversations/utils/Resolver.java +++ b/src/main/java/eu/siacs/conversations/utils/Resolver.java @@ -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() {