fix failure during connecting device when channelActive happens later than handleMessage
[netconf.git] / netconf / mdsal-netconf-monitoring / src / main / java / org / opendaylight / controller / config / yang / netconf / mdsal / monitoring / MonitoringToMdsalWriter.java
index 3e487b4db6045c248891122be3a8336c6fe826f9..0bd79fde0ce6a734ca8540e0738dcf64a87347ee 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.config.yang.netconf.mdsal.monitoring;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collection;
 import java.util.function.Consumer;
 import javax.annotation.Nullable;
@@ -52,11 +53,12 @@ public final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMoni
     }
 
     /**
-     * Invoke using blueprint
+     * Invoked using blueprint.
      */
     @Override
     public void close() {
-        runTransaction((tx) -> tx.delete(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(NetconfState.class)));
+        runTransaction((tx) -> tx.delete(LogicalDatastoreType.OPERATIONAL,
+                InstanceIdentifier.create(NetconfState.class)));
     }
 
     @Override
@@ -80,7 +82,8 @@ public final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMoni
 
     @Override
     public void onCapabilitiesChanged(Capabilities capabilities) {
-        runTransaction((tx) -> tx.put(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_INSTANCE_IDENTIFIER, capabilities));
+        runTransaction((tx) -> tx.put(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_INSTANCE_IDENTIFIER,
+                capabilities));
     }
 
     @Override
@@ -89,7 +92,7 @@ public final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMoni
     }
 
     /**
-     * Invoke using blueprint
+     * Invoked using blueprint.
      */
     public void start() {
         serverMonitoringDependency.registerCapabilitiesListener(this);
@@ -107,10 +110,10 @@ public final class MonitoringToMdsalWriter implements AutoCloseable, NetconfMoni
             }
 
             @Override
-            public void onFailure(Throwable t) {
-                LOG.warn("Unable to update netconf state", t);
+            public void onFailure(Throwable throwable) {
+                LOG.warn("Unable to update netconf state", throwable);
             }
-        });
+        }, MoreExecutors.directExecutor());
     }
 
     private static void updateSessions(WriteTransaction tx, Collection<Session> sessions) {