Fix a NPE on missing path 30/97130/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 10 Aug 2021 22:08:35 +0000 (00:08 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Aug 2021 06:46:24 +0000 (08:46 +0200)
If we have an action registration for a different path, we will end up
with a NPE. Handle this case and throw DOMActionNotAvailableException
instead of a NPE.

Change-Id: Icc01eb2f7b291285fc26392561553520ad784bf3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4ed468321be93927cc49ed797c5e02c0d847a259)

dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java

index 2a10b9aed5c8af0804bfc3eebd5300745dff8dae..9f93a946c25d161105af6184ac51ffdb9e4dcb05 100644 (file)
@@ -539,7 +539,13 @@ public final class DOMRpcRouter extends AbstractRegistration
 
         static ListenableFuture<? extends DOMActionResult> invoke(final DOMActionRoutingTableEntry entry,
                 final Absolute type, final DOMDataTreeIdentifier path, final ContainerNode input) {
-            return entry.getImplementations(path).get(0).invokeAction(type, path, input);
+            final List<DOMActionImplementation> impls = entry.getImplementations(path);
+            if (impls == null) {
+                return Futures.immediateFailedFuture(
+                    new DOMActionNotAvailableException("No implementation of Action %s available for %s", type, path));
+            }
+
+            return impls.get(0).invokeAction(type, path, input);
         }
 
         static ListenableFuture<? extends DOMRpcResult> invoke(final AbstractDOMRpcRoutingTableEntry entry,