Use simple Executor in NetconfDevice 01/106801/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 4 Jul 2023 16:34:00 +0000 (18:34 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 5 Jul 2023 00:01:51 +0000 (00:01 +0000)
Passing down ListenableExecutorService ends up being interesting, as it
is not clear what the actual lifecycle is. Luckily we can get by using a
simple Executor with Futures.submit(), which essentially performs the
same task.

This makes it clear that the service is not touched by anyone in the
stack and we can use any old Executor -- to the point of using
directExecutor() in NetconfDeviceTest.

Change-Id: I31fcfcb7b303046935392bffd6d50c8f83ec33a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeContext.java
apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java
apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologySetup.java
apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/AbstractNetconfTopology.java
apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfNodeHandler.java
plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDevice.java
plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceBuilder.java
plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java

index ea407fd9edc2f9045fcbee6fbfea832642b96fe5..dbbf12bdcb98a9a5d29115be921c969bf33ac604 100644 (file)
@@ -15,9 +15,8 @@ import akka.dispatch.OnComplete;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 import io.netty.util.concurrent.EventExecutor;
+import java.util.concurrent.Executor;
 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
 import org.opendaylight.controller.config.threadpool.ThreadPool;
 import org.opendaylight.mdsal.binding.api.DataBroker;
@@ -48,7 +47,7 @@ final class NetconfNodeContext implements AutoCloseable {
     private final BaseNetconfSchemas baseSchemas;
     private final NetconfClientConfigurationBuilderFactory builderFactory;
     private final ScheduledThreadPool keepaliveExecutor;
-    private final ListeningExecutorService processingExecutor;
+    private final Executor processingExecutor;
     private final DataBroker dataBroker;
     private final DOMMountPointService mountPointService;
     private final RemoteDeviceId remoteDeviceId;
@@ -70,8 +69,7 @@ final class NetconfNodeContext implements AutoCloseable {
         this.clientDispatcher = requireNonNull(clientDispatcher);
         this.eventExecutor = requireNonNull(eventExecutor);
         this.keepaliveExecutor = requireNonNull(keepaliveExecutor);
-        // FIXME: share a single instance!
-        this.processingExecutor = MoreExecutors.listeningDecorator(processingExecutor.getExecutor());
+        this.processingExecutor = processingExecutor.getExecutor();
         this.schemaManager = requireNonNull(schemaManager);
         this.dataBroker = requireNonNull(dataBroker);
         this.mountPointService = requireNonNull(mountPointService);
index 04e452f78335a0a6459b9f5eb6e3790107333d4d..228c94b73017e5a25c0badb54c3009f8d130214f 100644 (file)
@@ -13,13 +13,13 @@ import akka.actor.ActorSystem;
 import akka.util.Timeout;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import io.netty.util.concurrent.EventExecutor;
 import java.time.Duration;
 import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledExecutorService;
 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
 import org.opendaylight.controller.cluster.ActorSystemProvider;
@@ -85,7 +85,7 @@ public class NetconfTopologyManager
     private final ScheduledThreadPool keepaliveExecutor;
     private final ScheduledExecutorService keepaliveExecutorService;
     private final ThreadPool processingExecutor;
-    private final ListeningExecutorService processingExecutorService;
+    private final Executor processingExecutorService;
     private final ActorSystem actorSystem;
     private final EventExecutor eventExecutor;
     private final NetconfClientDispatcher clientDispatcher;
@@ -124,7 +124,7 @@ public class NetconfTopologyManager
         this.keepaliveExecutor = keepaliveExecutor;
         keepaliveExecutorService = keepaliveExecutor.getExecutor();
         this.processingExecutor = processingExecutor;
-        processingExecutorService = MoreExecutors.listeningDecorator(processingExecutor.getExecutor());
+        processingExecutorService = processingExecutor.getExecutor();
         actorSystem = requireNonNull(actorSystemProvider).getActorSystem();
         this.eventExecutor = requireNonNull(eventExecutor);
         this.clientDispatcher = requireNonNull(clientDispatcher);
index 7a0f3c0d99b9291a0f09809857e83b9fa9ad9b74..ecc8239cb3ccd0d06e05461b07531d110fdf0873 100644 (file)
@@ -10,9 +10,9 @@ package org.opendaylight.netconf.topology.singleton.impl.utils;
 import static java.util.Objects.requireNonNull;
 
 import akka.actor.ActorSystem;
-import com.google.common.util.concurrent.ListeningExecutorService;
 import io.netty.util.concurrent.EventExecutor;
 import java.time.Duration;
+import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledExecutorService;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
@@ -32,7 +32,7 @@ public class NetconfTopologySetup {
     private final InstanceIdentifier<Node> instanceIdentifier;
     private final Node node;
     private final ScheduledExecutorService keepaliveExecutor;
-    private final ListeningExecutorService processingExecutor;
+    private final Executor processingExecutor;
     private final ActorSystem actorSystem;
     private final EventExecutor eventExecutor;
     private final NetconfClientDispatcher netconfClientDispatcher;
@@ -83,7 +83,7 @@ public class NetconfTopologySetup {
         return node;
     }
 
-    public ListeningExecutorService getProcessingExecutor() {
+    public Executor getProcessingExecutor() {
         return processingExecutor;
     }
 
@@ -127,7 +127,7 @@ public class NetconfTopologySetup {
         private InstanceIdentifier<Node> instanceIdentifier;
         private Node node;
         private ScheduledExecutorService keepaliveExecutor;
-        private ListeningExecutorService processingExecutor;
+        private Executor processingExecutor;
         private ActorSystem actorSystem;
         private EventExecutor eventExecutor;
         private String topologyId;
@@ -218,11 +218,11 @@ public class NetconfTopologySetup {
             return this;
         }
 
-        ListeningExecutorService getProcessingExecutor() {
+        Executor getProcessingExecutor() {
             return processingExecutor;
         }
 
-        public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) {
+        public NetconfTopologySetupBuilder setProcessingExecutor(final Executor processingExecutor) {
             this.processingExecutor = processingExecutor;
             return this;
         }
index 931f716167e8cc65d4f9b112ccb54d04fed69c9c..8fef25b22e022a6a64c3b1b3477a009e591488da 100644 (file)
@@ -10,11 +10,11 @@ package org.opendaylight.netconf.topology.spi;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 import io.netty.util.concurrent.EventExecutor;
 import java.util.HashMap;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledExecutorService;
 import org.checkerframework.checker.lock.qual.Holding;
 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
 import org.opendaylight.controller.config.threadpool.ThreadPool;
@@ -51,8 +51,8 @@ public abstract class AbstractNetconfTopology {
     private final BaseNetconfSchemas baseSchemas;
     private final NetconfClientConfigurationBuilderFactory builderFactory;
 
-    protected final ScheduledThreadPool keepaliveExecutor;
-    protected final ListeningExecutorService processingExecutor;
+    protected final ScheduledExecutorService keepaliveExecutor;
+    protected final Executor processingExecutor;
     protected final DataBroker dataBroker;
     protected final DOMMountPointService mountPointService;
     protected final String topologyId;
@@ -65,8 +65,8 @@ public abstract class AbstractNetconfTopology {
         this.topologyId = requireNonNull(topologyId);
         this.clientDispatcher = clientDispatcher;
         this.eventExecutor = eventExecutor;
-        this.keepaliveExecutor = keepaliveExecutor;
-        this.processingExecutor = MoreExecutors.listeningDecorator(processingExecutor.getExecutor());
+        this.keepaliveExecutor = keepaliveExecutor.getExecutor();
+        this.processingExecutor = processingExecutor.getExecutor();
         this.schemaManager = requireNonNull(schemaManager);
         this.deviceActionFactory = deviceActionFactory;
         this.dataBroker = requireNonNull(dataBroker);
@@ -139,7 +139,7 @@ public abstract class AbstractNetconfTopology {
         // Instantiate the handler ...
         final var deviceId = NetconfNodeUtils.toRemoteDeviceId(nodeId, netconfNode);
         final var deviceSalFacade = createSalFacade(deviceId, netconfNode.requireLockDatastore());
-        final var nodeHandler = new NetconfNodeHandler(clientDispatcher, eventExecutor, keepaliveExecutor.getExecutor(),
+        final var nodeHandler = new NetconfNodeHandler(clientDispatcher, eventExecutor, keepaliveExecutor,
             baseSchemas, schemaManager, processingExecutor, builderFactory, deviceActionFactory, deviceSalFacade,
             deviceId, nodeId, netconfNode, nodeOptional);
 
index 9fa81131f174a675f2f7ee4ce6510d1d31aa72fe..d768f5842a529b7961e09a38935e7cce240e7c07 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.netconf.topology.spi;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.util.concurrent.ListeningExecutorService;
 import io.netty.util.concurrent.EventExecutor;
 import io.netty.util.concurrent.Future;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CancellationException;
+import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import org.checkerframework.checker.lock.qual.GuardedBy;
@@ -77,7 +77,7 @@ public final class NetconfNodeHandler extends AbstractRegistration implements Re
 
     public NetconfNodeHandler(final NetconfClientDispatcher clientDispatcher, final EventExecutor eventExecutor,
             final ScheduledExecutorService keepaliveExecutor, final BaseNetconfSchemas baseSchemas,
-            final SchemaResourceManager schemaManager, final ListeningExecutorService processingExecutor,
+            final SchemaResourceManager schemaManager, final Executor processingExecutor,
             final NetconfClientConfigurationBuilderFactory builderFactory,
             final DeviceActionFactory deviceActionFactory, final RemoteDeviceHandler delegate,
             final RemoteDeviceId deviceId, final NodeId nodeId, final NetconfNode node,
index 9cf46db79b842bb95ff042b95b0c28c31d97c1ba..9d9e4f1a6ecaf07cede438f43a21d5c7083aa1c4 100644 (file)
@@ -19,7 +19,6 @@ import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
 import java.io.Serial;
@@ -32,6 +31,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
 import java.util.stream.Collectors;
 import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.eclipse.jdt.annotation.NonNull;
@@ -83,7 +83,7 @@ public class NetconfDevice implements RemoteDevice<NetconfDeviceCommunicator> {
 
     private static final QName RFC8528_SCHEMA_MOUNTS_QNAME = QName.create(
         SchemaMountConstants.RFC8528_MODULE, "schema-mounts").intern();
-    private static final YangInstanceIdentifier RFC8528_SCHEMA_MOUNTS = YangInstanceIdentifier.create(
+    private static final YangInstanceIdentifier RFC8528_SCHEMA_MOUNTS = YangInstanceIdentifier.of(
         NodeIdentifier.create(RFC8528_SCHEMA_MOUNTS_QNAME));
 
     protected final RemoteDeviceId id;
@@ -94,7 +94,7 @@ public class NetconfDevice implements RemoteDevice<NetconfDeviceCommunicator> {
     protected final List<Registration> sourceRegistrations = new ArrayList<>();
 
     private final RemoteDeviceHandler salFacade;
-    private final ListeningExecutorService processingExecutor;
+    private final Executor processingExecutor;
     private final DeviceActionFactory deviceActionFactory;
     private final NetconfDeviceSchemasResolver stateSchemasResolver;
     private final NotificationHandler notificationHandler;
@@ -108,15 +108,14 @@ public class NetconfDevice implements RemoteDevice<NetconfDeviceCommunicator> {
     private NetconfMessageTransformer messageTransformer;
 
     public NetconfDevice(final SchemaResourcesDTO schemaResourcesDTO, final BaseNetconfSchemas baseSchemas,
-            final RemoteDeviceId id, final RemoteDeviceHandler salFacade,
-            final ListeningExecutorService globalProcessingExecutor, final boolean reconnectOnSchemasChange) {
+            final RemoteDeviceId id, final RemoteDeviceHandler salFacade, final Executor globalProcessingExecutor,
+            final boolean reconnectOnSchemasChange) {
         this(schemaResourcesDTO, baseSchemas, id, salFacade, globalProcessingExecutor, reconnectOnSchemasChange, null);
     }
 
     public NetconfDevice(final SchemaResourcesDTO schemaResourcesDTO, final BaseNetconfSchemas baseSchemas,
-            final RemoteDeviceId id, final RemoteDeviceHandler salFacade,
-            final ListeningExecutorService globalProcessingExecutor, final boolean reconnectOnSchemasChange,
-            final DeviceActionFactory deviceActionFactory) {
+            final RemoteDeviceId id, final RemoteDeviceHandler salFacade, final Executor globalProcessingExecutor,
+            final boolean reconnectOnSchemasChange, final DeviceActionFactory deviceActionFactory) {
         this.baseSchemas = requireNonNull(baseSchemas);
         this.id = id;
         this.reconnectOnSchemasChange = reconnectOnSchemasChange;
@@ -144,8 +143,9 @@ public class NetconfDevice implements RemoteDevice<NetconfDeviceCommunicator> {
         final BaseSchema baseSchema = resolveBaseSchema(remoteSessionCapabilities.isNotificationsSupported());
         final NetconfDeviceRpc initRpc = new NetconfDeviceRpc(baseSchema.getEffectiveModelContext(), listener,
             new NetconfMessageTransformer(baseSchema.getMountPointContext(), false, baseSchema));
-        final ListenableFuture<DeviceSources> sourceResolverFuture = processingExecutor.submit(
-            new DeviceSourcesResolver(id, baseSchema, initRpc, remoteSessionCapabilities, stateSchemasResolver));
+        final ListenableFuture<DeviceSources> sourceResolverFuture = Futures.submit(
+            new DeviceSourcesResolver(id, baseSchema, initRpc, remoteSessionCapabilities, stateSchemasResolver),
+            processingExecutor);
 
         if (shouldListenOnSchemaChange(remoteSessionCapabilities)) {
             registerToBaseNetconfStream(initRpc, listener);
index 8207d81115dac376def9bfc089819b0bbebb6da9..7ce98d0b7550a9f41ca6a2780152f887ebb0f2b0 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.netconf.client.mdsal;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.util.concurrent.ListeningExecutorService;
+import java.util.concurrent.Executor;
 import org.opendaylight.netconf.client.mdsal.NetconfDevice.SchemaResourcesDTO;
 import org.opendaylight.netconf.client.mdsal.api.BaseNetconfSchemas;
 import org.opendaylight.netconf.client.mdsal.api.DeviceActionFactory;
@@ -21,13 +21,10 @@ public class NetconfDeviceBuilder {
     private SchemaResourcesDTO schemaResourcesDTO;
     private RemoteDeviceId id;
     private RemoteDeviceHandler salFacade;
-    private ListeningExecutorService globalProcessingExecutor;
+    private Executor globalProcessingExecutor;
     private DeviceActionFactory deviceActionFactory;
     private BaseNetconfSchemas baseSchemas;
 
-    public NetconfDeviceBuilder() {
-    }
-
     public NetconfDeviceBuilder setReconnectOnSchemasChange(final boolean reconnectOnSchemasChange) {
         this.reconnectOnSchemasChange = reconnectOnSchemasChange;
         return this;
@@ -48,7 +45,7 @@ public class NetconfDeviceBuilder {
         return this;
     }
 
-    public NetconfDeviceBuilder setGlobalProcessingExecutor(final ListeningExecutorService globalProcessingExecutor) {
+    public NetconfDeviceBuilder setGlobalProcessingExecutor(final Executor globalProcessingExecutor) {
         this.globalProcessingExecutor = globalProcessingExecutor;
         return this;
     }
index 99dff81d55cd91c2ab23be64742ab2b586ea6e15..9b1acf1158c131afba81f67f560baba50b5b059a 100644 (file)
@@ -26,20 +26,16 @@ import static org.mockito.Mockito.verify;
 import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.Executors;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.opendaylight.mdsal.dom.api.DOMNotification;
@@ -129,7 +125,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -162,7 +158,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -214,7 +210,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setBaseSchemas(BASE_SCHEMAS)
                 .setId(getId())
                 .setSalFacade(facade)
@@ -260,7 +256,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -293,7 +289,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -329,7 +325,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -359,7 +355,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -375,7 +371,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
 
         netconfSpy.onRemoteSessionUp(sessionCaps.replaceModuleCaps(moduleBasedCaps), listener);
 
-        final ArgumentCaptor<NetconfDeviceSchema> argument =  ArgumentCaptor.forClass(NetconfDeviceSchema.class);
+        final ArgumentCaptor<NetconfDeviceSchema> argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class);
         verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class),
             any(RemoteDeviceServices.class));
         argument.getValue().capabilities().resolvedCapabilities()
@@ -394,7 +390,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
                 getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -409,7 +405,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class),
                 any(RemoteDeviceServices.class));
 
-        List<String> notificationModulesName = Arrays.asList(
+        List<String> notificationModulesName = List.of(
                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714
                         .$YangModuleInfoImpl.getInstance().getName().toString(),
                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715
@@ -432,7 +428,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
                 getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
@@ -469,14 +465,14 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
                 getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
         final NetconfDevice device = new NetconfDeviceBuilder()
                 .setSchemaResourcesDTO(schemaResourcesDTO)
-                .setGlobalProcessingExecutor(getExecutor())
+                .setGlobalProcessingExecutor(MoreExecutors.directExecutor())
                 .setId(getId())
                 .setSalFacade(facade)
                 .setBaseSchemas(BASE_SCHEMAS)
                 .build();
         final NetconfDevice netconfSpy = spy(device);
 
-        final NetconfSessionPreferences sessionCaps = getSessionCaps(false, Collections.emptyList());
+        final NetconfSessionPreferences sessionCaps = getSessionCaps(false, List.of());
 
         final Map<QName, CapabilityOrigin> moduleBasedCaps = new HashMap<>();
         moduleBasedCaps.put(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714
@@ -538,10 +534,6 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
         return new RemoteDeviceId("test-D", InetSocketAddress.createUnresolved("localhost", 22));
     }
 
-    public ListeningExecutorService getExecutor() {
-        return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
-    }
-
     public NetconfSessionPreferences getSessionCaps(final boolean addMonitor,
                                                     final Collection<String> additionalCapabilities) {
         final var capabilities = new ArrayList<String>();
@@ -555,9 +547,6 @@ public class NetconfDeviceTest extends AbstractTestModelTest {
     }
 
     public NetconfDeviceCommunicator getListener() throws Exception {
-        final NetconfDeviceCommunicator remoteDeviceCommunicator = mockCloseableClass(NetconfDeviceCommunicator.class);
-//        doReturn(Futures.immediateFuture(rpcResult))
-//                .when(remoteDeviceCommunicator).sendRequest(any(NetconfMessage.class), any(QName.class));
-        return remoteDeviceCommunicator;
+        return mockCloseableClass(NetconfDeviceCommunicator.class);
     }
 }