Fixed NPE in LeafNodeCodecContext.domValueFromString
[mdsal.git] / 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