From 3b229907bacd02c1a37174d84945a34c468c1d95 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 31 May 2022 20:25:03 +0200 Subject: [PATCH] Reduce ReconnectingStrategyListener nesting We do not need to nest the two listeners into each other. This is the first step to eliminating both of them. Change-Id: I3af5797dcccc3e82e9c28731b082e1f4014aba74 Signed-off-by: Robert Varga --- .../nettyutil/NetconfSessionPromise.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java index 5aba2df34e..f411534452 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java @@ -83,7 +83,6 @@ final class NetconfSessionPromise extends DefaultPromi @Override public void operationComplete(final ChannelFuture cf) { synchronized (NetconfSessionPromise.this) { - LOG.debug("Promise {} connection resolved", NetconfSessionPromise.this); // Triggered when a connection attempt is resolved. @@ -118,28 +117,28 @@ final class NetconfSessionPromise extends DefaultPromi pending = rf; } } + } + + private class ReconnectingStrategyListener implements FutureListener { + @Override + public void operationComplete(final Future sf) { + synchronized (NetconfSessionPromise.this) { + // Triggered when a connection attempt is to be made. + checkState(pending.equals(sf)); - private class ReconnectingStrategyListener implements FutureListener { - @Override - public void operationComplete(final Future sf) { - synchronized (NetconfSessionPromise.this) { - // Triggered when a connection attempt is to be made. - checkState(pending.equals(sf)); - - /* - * The promise we gave out could have been cancelled, - * which cascades to the reconnect attempt getting - * cancelled, but there is a slight race window, where - * the reconnect attempt is already enqueued, but the - * listener has not yet been notified -- if cancellation - * happens at that point, we need to catch it here. - */ - if (!isCancelled()) { - if (sf.isSuccess()) { - connect(); - } else { - setFailure(sf.cause()); - } + /* + * The promise we gave out could have been cancelled, + * which cascades to the reconnect attempt getting + * cancelled, but there is a slight race window, where + * the reconnect attempt is already enqueued, but the + * listener has not yet been notified -- if cancellation + * happens at that point, we need to catch it here. + */ + if (!isCancelled()) { + if (sf.isSuccess()) { + connect(); + } else { + setFailure(sf.cause()); } } } -- 2.36.6