Fixed NPE in LeafNodeCodecContext.domValueFromString 64/29864/2
authorTony Tkacik <ttkacik@cisco.com>
Wed, 18 Nov 2015 15:01:36 +0000 (16:01 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 18 Nov 2015 15:07:45 +0000 (15:07 +0000)
Change-Id: I089efca778430fd04a53de6e5a025564317acd62
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/LeafNodeCodecContext.java

index c8e1999894bfa479bb4b103f4ebb023e20b9c452..787ae6c9b5b556593dcc3c69b68e95ab6333b15a 100644 (file)
@@ -93,8 +93,13 @@ final class LeafNodeCodecContext<D extends DataObject> extends NodeCodecContext<
     private static Object domValueFromString(final Codec<Object, Object> codec, final TypeDefinition<?> type,
     Object defaultValue) {
         TypeDefinitionAwareCodec typeDefAwareCodec = TypeDefinitionAwareCodec.from(type);
-        Object castedDefaultValue = typeDefAwareCodec.deserialize((String) defaultValue);
-        return codec.deserialize(castedDefaultValue);
+        if (typeDefAwareCodec != null) {
+            Object castedDefaultValue = typeDefAwareCodec.deserialize((String) defaultValue);
+            return codec.deserialize(castedDefaultValue);
+        }
+        // FIXME: BUG-4647 Refactor / redesign this to throw hard error,
+        // once BUG-4638 is fixed and will provide proper getDefaultValue implementation.
+        return null;
     }
 
     @Override