BUG 5125: Fix NPE on module's with unknown namespace 86/34886/2
authorTomas Cere <tcere@cisco.com>
Thu, 18 Feb 2016 10:24:04 +0000 (11:24 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 24 Feb 2016 09:18:47 +0000 (09:18 +0000)
port of:
https://git.opendaylight.org/gerrit/#/c/33904/2

Change-Id: Ib5e4f3d01a710e1a8e4f11bb01ba26f643d88ab0
Signed-off-by: Tomas Cere <tcere@cisco.com>
opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/EditConfig.java

index 914ff200068992b250f9d21f6feea395c449394c..cf0afb039ab28830987b09b153720c073ba48cdf 100644 (file)
@@ -165,6 +165,11 @@ public class EditConfig extends AbstractSingletonNetconfOperation {
         try {
             //returns module with newest revision since findModuleByNamespace returns a set of modules and we only need the newest one
             final Module module = schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(new URI(namespace), null);
+            if (module == null) {
+                // no module is present with this namespace
+                throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
+                        ErrorType.application, ErrorTag.unknown_namespace, ErrorSeverity.error);
+            }
             DataSchemaNode schemaNode = module.getDataChildByName(element.getName());
             if (schemaNode != null) {
                 dataSchemaNode = Optional.of(module.getDataChildByName(element.getName()));