From: Robert Varga Date: Tue, 18 Oct 2022 18:45:14 +0000 (+0200) Subject: Use Future.cause() for completion checking X-Git-Tag: v4.0.3~33 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=netconf.git;a=commitdiff_plain;h=44d23b752c46b110188ebc9371a0d459c408bebc Use Future.cause() for completion checking We know the future has completed, hence nullability of Future.cause() is a quicker check for success. Change-Id: Ie7baadb7fd744a8b7cfd58b01097997e71045ccd Signed-off-by: Robert Varga --- diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java index 89c0be1068..59f3e450b9 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java @@ -336,11 +336,12 @@ public abstract class AbstractNetconfSessionNegotiator { - if (!f.isSuccess()) { - LOG.info("Failed to send message {} on channel {}", msg, channel, f.cause()); - negotiationFailed(f.cause()); + protected void sendMessage(final NetconfMessage msg) { + channel.writeAndFlush(msg).addListener(f -> { + final var cause = f.cause(); + if (cause != null) { + LOG.info("Failed to send message {} on channel {}", msg, channel, cause); + negotiationFailed(cause); } else { LOG.trace("Message {} sent to socket on channel {}", msg, channel); }