Use Future.cause() for completion checking
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / AbstractNetconfSessionNegotiator.java
index 89c0be106837c21a907587dedca8dcb491b20a39..59f3e450b9c35b5d137bc391531a9c7a6ee28bf7 100644 (file)
@@ -336,11 +336,12 @@ public abstract class AbstractNetconfSessionNegotiator<S extends AbstractNetconf
      *
      * @param msg Message which should be sent.
      */
-    protected final void sendMessage(final NetconfMessage msg) {
-        this.channel.writeAndFlush(msg).addListener(f -> {
-            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);
             }