BUG-8697: select correct transformer for schemaless netconf mounts 14/59514/2
authorGwenael Lambrouin <gwenael.lambrouin@b-com.com>
Thu, 22 Jun 2017 12:27:42 +0000 (14:27 +0200)
committerTomas Cere <tcere@cisco.com>
Tue, 27 Jun 2017 08:50:35 +0000 (10:50 +0200)
Getting or editing the configuration of a schemaless-mounted netconf device
from the code of an ODL application results in a NullPointerException.

This patch fixes the NetconfBaseOps constructor so that the RPC structure
transformer dedicated to schemaless mount points is actually selected.

Change-Id: Ib0b2d1c9910613f4354bdcb4f1c56e9be36a95b2
Signed-off-by: Gwenael Lambrouin <gwenael.lambrouin@b-com.com>
(cherry picked from commit 32621d57701de889651097ce5c1bfc3bb5f43ce9)

netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacade.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOps.java

index 2e33b57beb86f484d147b43d3982c74a7d397cd4..917b8241e6c17a6e720edd09da5dce0cc7d98d1c 100644 (file)
@@ -266,7 +266,7 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
      * DOMRpcService proxy that attaches reset-keepalive-task and schedule
      * request-timeout-task to each RPC invocation.
      */
-    private static final class KeepaliveDOMRpcService implements DOMRpcService {
+    public static final class KeepaliveDOMRpcService implements DOMRpcService {
 
         private final DOMRpcService deviceRpc;
         private ResetKeepalive resetKeepaliveTask;
@@ -281,6 +281,10 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
             this.executor = executor;
         }
 
+        public DOMRpcService getDeviceRpc() {
+            return deviceRpc;
+        }
+
         @Nonnull
         @Override
         public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final SchemaPath type,
index d12a97c8bd4979d7a2f87942f39d5e54d7d11d20..debd460936ecfb524da81fd2385688a47138fd28 100644 (file)
@@ -35,6 +35,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade.KeepaliveDOMRpcService;
 import org.opendaylight.netconf.sal.connect.netconf.sal.SchemalessNetconfDeviceRpc;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.copy.config.input.target.ConfigTarget;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.EditContent;
@@ -63,7 +64,9 @@ public final class NetconfBaseOps {
     public NetconfBaseOps(final DOMRpcService rpc, final SchemaContext schemaContext) {
         this.rpc = rpc;
         this.schemaContext = schemaContext;
-        if (rpc instanceof SchemalessNetconfDeviceRpc) {
+
+        if ((rpc instanceof KeepaliveDOMRpcService)
+                && (((KeepaliveDOMRpcService) rpc).getDeviceRpc() instanceof SchemalessNetconfDeviceRpc)) {
             this.transformer = new SchemalessRpcStructureTransformer();
         } else {
             this.transformer = new NetconfRpcStructureTransformer(schemaContext);