From f5ee2cc601ad1027f5cd53cd779e76dc0f0f15ec Mon Sep 17 00:00:00 2001 From: Tomas Cere Date: Thu, 18 Feb 2016 11:24:04 +0100 Subject: [PATCH] BUG 5125: Fix NPE on module's with unknown namespace port of: https://git.opendaylight.org/gerrit/#/c/33904/2 Change-Id: Ib5e4f3d01a710e1a8e4f11bb01ba26f643d88ab0 Signed-off-by: Tomas Cere --- .../controller/netconf/mdsal/connector/ops/EditConfig.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/EditConfig.java b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/EditConfig.java index 914ff20006..cf0afb039a 100644 --- a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/EditConfig.java +++ b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/EditConfig.java @@ -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())); -- 2.36.6