diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java index 8510488c68..1a928f8c23 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java @@ -600,7 +600,7 @@ public class DnsNameResolver extends InetNameResolver { Promise promise, DnsCache resolveCache) { final List cachedEntries = resolveCache.get(hostname, additionals); - if (cachedEntries == null || cachedEntries.isEmpty()) { + if (cachedEntries == null) { return false; } @@ -608,7 +608,9 @@ public class DnsNameResolver extends InetNameResolver { Throwable cause = null; synchronized (cachedEntries) { final int numEntries = cachedEntries.size(); - assert numEntries > 0; + if (numEntries == 0) { + return false; + } if (cachedEntries.get(0).cause() != null) { cause = cachedEntries.get(0).cause(); @@ -730,7 +732,7 @@ public class DnsNameResolver extends InetNameResolver { Promise> promise, DnsCache resolveCache) { final List cachedEntries = resolveCache.get(hostname, additionals); - if (cachedEntries == null || cachedEntries.isEmpty()) { + if (cachedEntries == null) { return false; } @@ -738,7 +740,9 @@ public class DnsNameResolver extends InetNameResolver { Throwable cause = null; synchronized (cachedEntries) { final int numEntries = cachedEntries.size(); - assert numEntries > 0; + if (numEntries == 0) { + return false; + } if (cachedEntries.get(0).cause() != null) { cause = cachedEntries.get(0).cause();