Simplify error checking in writeWithPendingDetection()
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / handler / ssh / client / AsyncSshHandlerWriter.java
index 01284e308a8e2b3636af9915b90e57cb02387da3..204f8e5df8a9156a715fb8372bed3752316c997a 100644 (file)
@@ -98,19 +98,19 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
                 // window resize write would try to write the message on an already locked channelSession,
                 // while the pending write was in progress from the write callback
                 synchronized (asyncInLock) {
+                    final var cause = future.getException();
                     if (LOG.isTraceEnabled()) {
-                        LOG.trace(
-                            "Ssh write request finished on channel: {} with result: {}: and ex:{}, message: {}",
-                            ctx.channel(), future.isWritten(), future.getException(), byteBufToString(byteBufMsg));
+                        LOG.trace("Ssh write request finished on channel: {} with ex: {}, message: {}", ctx.channel(),
+                            cause, byteBufToString(byteBufMsg));
                     }
 
                     // Notify success or failure
-                    if (future.isWritten()) {
-                        promise.setSuccess();
-                    } else {
+                    if (cause != null) {
                         LOG.warn("Ssh write request failed on channel: {} for message: {}", ctx.channel(),
-                                byteBufToString(byteBufMsg), future.getException());
-                        promise.setFailure(future.getException());
+                            byteBufToString(byteBufMsg), cause);
+                        promise.setFailure(cause);
+                    } else {
+                        promise.setSuccess();
                     }
 
                     //rescheduling message from queue after successfully sent