From 5e42e758bebe489574ee1dc6ed8b1ed3db54792b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 25 Jun 2018 21:14:37 +0200 Subject: [PATCH] Also remove the id from the DnsQueryContextManager if query fails due parent Channel activation error. Motivation: Whenever we fail the query we should also remove the id from the DnsQueryContextManager. Modifications: Remove the id from the DnsQueryContextManager if we fail the query because the channel failed to become active. Result: More correct code. --- .../src/main/java/io/netty/resolver/dns/DnsQueryContext.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java index 12196f184c..3aee7686d3 100644 --- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java +++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java @@ -115,10 +115,13 @@ final class DnsQueryContext { } else { parent.channelFuture.addListener(new GenericFutureListener>() { @Override - public void operationComplete(Future future) throws Exception { + public void operationComplete(Future future) { if (future.isSuccess()) { writeQuery(query, writePromise); } else { + // Remove the id from the manager as we fail the query. + parent.queryContextManager.remove(nameServerAddr(), id); + Throwable cause = future.cause(); promise.tryFailure(cause); writePromise.setFailure(cause);