Bug 4969: NPE in JSONCodecFactory by attempt to find codec for a leafref
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / codec / xml / XmlStreamUtils.java
index b1f9805517e5248471cfc8d07a7ee8129ead1da1..eeda8954c79231371567d674eda12e8b3fc6b482 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Verify;
 import java.net.URI;
 import java.util.Map.Entry;
 import javax.annotation.Nonnull;
@@ -108,6 +109,7 @@ public class XmlStreamUtils {
         if (schemaContext.isPresent() && baseType instanceof LeafrefTypeDefinition) {
             LeafrefTypeDefinition leafrefTypeDefinition = (LeafrefTypeDefinition) baseType;
             baseType = SchemaContextUtil.getBaseTypeForLeafRef(leafrefTypeDefinition, schemaContext.get(), schemaNode);
+            Verify.verifyNotNull(baseType, "Unable to find base type for leafref node '%s'.", schemaNode.getPath());
         }
 
         writeValue(writer, baseType, value, parent);