Fix NetconfMessage not sent on EmbeddedChannel 16/108116/7
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>
Mon, 2 Oct 2023 10:41:53 +0000 (13:41 +0300)
committerRobert Varga <nite@hq.sk>
Thu, 12 Oct 2023 20:42:49 +0000 (20:42 +0000)
The EmbeddedChannel implementation uses built-in implementation
for event loop (EmbeddedEventLoop) which has no own executor.
The tasks placed via execute() method are queued but not executed
unless predefined events like channel closure.

Explicit triggering of pending tasks processing resolves the issue
for now, but this needs to be revisited.

JIRA: NETCONF-1106
Change-Id: Ief1d9566651c39e10310c961e5899324e73fa923
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSession.java
protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfSubsystem.java

index 7f1009613af2bee37144fe03a79172f7a7118505..3eaf83156f3494677196a20b808ae36a0e2588b4 100644 (file)
@@ -15,6 +15,7 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
 import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.channel.embedded.EmbeddedChannel;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import io.netty.handler.codec.MessageToByteEncoder;
 import java.io.EOFException;
@@ -92,6 +93,14 @@ public abstract class AbstractNetconfSession<S extends NetconfSession, L extends
             }
         });
 
+        // FIXME: NETCONF-1106: this is a workaround for netconf-server's NetconfSubsystem using EmbeddedChannel instead
+        //                      of correctly integrating with the underlying transport channel
+        if (channel instanceof EmbeddedChannel embeddedChannel) {
+            // Embedded event loop implementation has no executor, it requires explicit invocation to process
+            synchronized (channel) {
+                embeddedChannel.runPendingTasks();
+            }
+        }
         return promise;
     }
 
index 50ae962e174f9a3e24ca17d580bf95ea1eb1b4af..7571b7130067352bcc52d06a125a81194cb60efa 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.netconf.shaded.sshd.server.command.AsyncCommand;
 
 final class NetconfSubsystem extends AbstractCommandSupport
         implements AsyncCommand, ChannelSessionAware, ChannelDataReceiver {
+    // FIXME: NETCONF-1106: do not use EmbeddedChannel here!
     private final EmbeddedChannel innerChannel = new EmbeddedChannel();
     private final ServerChannelInitializer channelInitializer;