diff options
author | Chiachang Wang <chiachangwang@google.com> | 2019-07-08 14:33:12 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-07-08 14:33:12 -0700 |
commit | 88e29bf0717b946baeaae0ab89179323da45ab8c (patch) | |
tree | 8e99ba03e470f50ecb9c69feef771340428ab3ec /src | |
parent | 3a59eab5a9ab5d70d622312f8ae78b62b3c05a46 (diff) | |
parent | f20c7f3c3335d1275a115c8bb853f84ca46169a8 (diff) |
Merge "Use UnknownHostException directly without casting it" am: 692abb71d9
am: f20c7f3c33
Change-Id: Ia9350b374b5a4b822898f44c9b322a524f9b0cda
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/networkstack/util/DnsUtils.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/com/android/networkstack/util/DnsUtils.java b/src/com/android/networkstack/util/DnsUtils.java index e68976a..2ea5ed8 100644 --- a/src/com/android/networkstack/util/DnsUtils.java +++ b/src/com/android/networkstack/util/DnsUtils.java @@ -80,7 +80,7 @@ public class DnsUtils { if (result.size() == 0) { logger.log("FAIL: " + errorMsg.toString()); - throw new UnknownHostException(errorMsg.toString()); + throw new UnknownHostException(host); } logger.log("OK: " + host + " " + result.toString()); return result.toArray(new InetAddress[0]); @@ -134,20 +134,19 @@ public class DnsUtils { TrafficStats.setThreadStatsTag(oldTag); + String errorMsg = null; List<InetAddress> result = null; - Exception exception = null; try { result = resultRef.get(timeoutMs, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { - exception = e; + errorMsg = e.getMessage(); } catch (TimeoutException | InterruptedException e) { - exception = new UnknownHostException("Timeout"); + errorMsg = "Timeout"; } finally { - logDnsResult(result, watch.stop() /* latency */, logger, type, - exception != null ? exception.getMessage() : "" /* errorMsg */); + logDnsResult(result, watch.stop() /* latency */, logger, type, errorMsg); } - if (null != exception) throw (UnknownHostException) exception; + if (null != errorMsg) throw new UnknownHostException(host); return result.toArray(new InetAddress[0]); } |