From f194aedbf0a715f8c18b3eca23424e2d2b4dd2b3 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Tue, 4 Jun 2019 08:13:44 -0400 Subject: [PATCH] Close delegate resolver from RoundRobinInetAddressResolver (#9214) Motivation: RoundRobinDnsAddressResolverGroup ultimately opens UDP ports for DNS resolution. Callers likely expect that RoundRobinDnsAddressResolverGroup#close() will close those ports, but that is not currently true (see #9212). Modifications: Overrode RoundRobinInetAddressResolver#close() to close the delegate name resolver, which in turn closes any UDP ports used for name resolution. Result: RoundRobinDnsAddressResolverGroup#close() closes UDP ports as expected. This fixes #9212. --- .../io/netty/resolver/RoundRobinInetAddressResolver.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java b/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java index f505328a39..0a72a730a6 100644 --- a/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java +++ b/resolver/src/main/java/io/netty/resolver/RoundRobinInetAddressResolver.java @@ -100,4 +100,9 @@ public class RoundRobinInetAddressResolver extends InetNameResolver { private static int randomIndex(int numAddresses) { return numAddresses == 1 ? 0 : PlatformDependent.threadLocalRandom().nextInt(numAddresses); } + + @Override + public void close() { + nameResolver.close(); + } }