Bug 383 - exception raised if key part of URI is incorrect 26/5326/3
authorJozef Gloncak <jgloncak@cisco.com>
Fri, 14 Feb 2014 10:14:12 +0000 (11:14 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Wed, 26 Feb 2014 13:42:54 +0000 (14:42 +0100)
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 <jgloncak@cisco.com>
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend

index 482dcf8e8b37e5427c2470122bae9a15e3189a84..66e5cbf910fa159fcabb76a02326de23b069737d 100644 (file)
@@ -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);
     }