Bug 8803: check for null return NamespaceContext.getNamespaceURI() 67/60767/2
authorIgor Foltin <igor.foltin@pantheon.tech>
Wed, 26 Jul 2017 11:14:06 +0000 (13:14 +0200)
committerIgor Foltin <igor.foltin@pantheon.tech>
Wed, 26 Jul 2017 11:14:06 +0000 (13:14 +0200)
commitc53dce13e4d9de6df1a465c86d8e8574e7636614
tree9221975055c643b91c0b59f6a07206ab24945a74
parent2671dcb87d3717b0b82e4404d02593d99300399b
Bug 8803: check for null return NamespaceContext.getNamespaceURI()

The javadoc indicates that for unbound prefixes this method should be
returning NULL_NS_URI (which is defined as an empty string), and there
is no mention of the possibility of returning null anywhere.

Nevertheless JDK8-default XMLOutputWriter returns null for unbound
prefixes, which leads to an infinite loop in RandomPrefix.

Fix this by adding an explicit check for null, too.

Change-Id: Ib8af7d03eb59b004f2fcb4d1806c0f4f256a974a
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9946267ef128228dad7d6cc9dd5319bfad081756)
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/RandomPrefix.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8803Test.java [new file with mode: 0644]
yang/yang-data-codec-xml/src/test/resources/bug8803/bar.yang [new file with mode: 0644]
yang/yang-data-codec-xml/src/test/resources/bug8803/baz.yang [new file with mode: 0644]
yang/yang-data-codec-xml/src/test/resources/bug8803/foo.xml [new file with mode: 0644]
yang/yang-data-codec-xml/src/test/resources/bug8803/foo.yang [new file with mode: 0644]