From: Jozef Gloncak Date: Fri, 14 Feb 2014 10:14:12 +0000 (+0100) Subject: Bug 383 - exception raised if key part of URI is incorrect X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~358^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=8304daea948c306cbdaf9ba4edb4b64e9840f8d9;hp=-c Bug 383 - exception raised if key part of URI is incorrect Null pointer exception was caused for case when it wasn't possible to decode key part of URI (null value was returned) For case when key leaf type was identityref and wasn't specified as module_name:identity_name NullPointerException was raised. Change-Id: I6343d98e6549c02906628c78f61f97c18b244fe4 Signed-off-by: Jozef Gloncak --- 8304daea948c306cbdaf9ba4edb4b64e9840f8d9 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend index 482dcf8e8b..66e5cbf910 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend @@ -549,12 +549,18 @@ class ControllerContext implements SchemaServiceListener { val typedef = (node as LeafSchemaNode).type; var decoded = TypeDefinitionAwareCodec.from(typedef)?.deserialize(urlDecoded) + var additionalInfo = "" if(decoded === null) { var baseType = RestUtil.resolveBaseTypeFrom(typedef) if(baseType instanceof IdentityrefTypeDefinition) { decoded = toQName(urlDecoded) + additionalInfo = "For key which is of type identityref it should be in format module_name:identity_name." } } + if (decoded === null) { + throw new ResponseException(BAD_REQUEST, uriValue + " from URI can't be resolved. "+ additionalInfo ) + } + map.put(node.QName, decoded); }