BUG-8697: select correct transformer for schemaless netconf mounts 68/59068/2
authorGwenael Lambrouin <gwenael.lambrouin@b-com.com>
Thu, 22 Jun 2017 12:27:42 +0000 (14:27 +0200)
committerGwenael Lambrouin <gwenael.lambrouin@b-com.com>
Thu, 22 Jun 2017 12:27:54 +0000 (14:27 +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>
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 c450ac68fecd83c40d8eff6c306e30d02e6b35c1..1f22df7610e3b91f3421d7c525830a00637b67f1 100644 (file)
@@ -260,14 +260,14 @@ 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;
         private final long defaultRequestTimeoutMillis;
         private final ScheduledExecutorService executor;
 
-        public KeepaliveDOMRpcService(final DOMRpcService deviceRpc, final ResetKeepalive resetKeepaliveTask,
+        KeepaliveDOMRpcService(final DOMRpcService deviceRpc, final ResetKeepalive resetKeepaliveTask,
                 final long defaultRequestTimeoutMillis, final ScheduledExecutorService executor) {
             this.deviceRpc = deviceRpc;
             this.resetKeepaliveTask = resetKeepaliveTask;
@@ -275,6 +275,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, final NormalizedNode<?, ?> input) {
index 8c51218ef96e0ec1ddd368855156d5b04c1bf335..904234b4c775c8f937042f4793c421752e6dc919 100644 (file)
@@ -35,6 +35,8 @@ 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;
+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 +65,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);