From: Martin Sunal Date: Mon, 20 Jan 2014 12:12:20 +0000 (+0100) Subject: NPE prevention in log X-Git-Tag: yangtools-0.6.0~68 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=5cd62cd195348cd72e54c16e2aee9d1e30abccb6;p=yangtools.git NPE prevention in log - potential BUG 326 Signed-off-by: Martin Sunal --- diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtils.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtils.java index 63fb0a3772..ca66967f9d 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtils.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtils.java @@ -155,10 +155,13 @@ public class XmlDocumentUtils { element.setAttribute("xmlns:" + prefix, value.getNamespace().toString()); element.setTextContent(prefix + ":" + value.getLocalName()); } else { + Object value = node.getValue(); logger.debug("Value of {}:{} is not instance of QName but is {}", baseType.getQName().getNamespace(), // baseType.getQName().getLocalName(), // - node.getValue().getClass()); - element.setTextContent(String.valueOf(node.getValue())); + node != null ? value.getClass() : "null"); + if (value != null) { + element.setTextContent(String.valueOf(value)); + } } } else { if (node.getValue() != null) {