Bug 8803: check for null return NamespaceContext.getNamespaceURI() 36/60736/4
authorIgor Foltin <igor.foltin@pantheon.tech>
Tue, 25 Jul 2017 15:18:39 +0000 (17:18 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 25 Jul 2017 18:17:39 +0000 (20:17 +0200)
commit9946267ef128228dad7d6cc9dd5319bfad081756
tree42508dd7a293b306b40a94f8b768137832aa1807
parentf834e1d74ac46869be095e2fae49dc6895393736
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>
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]