[YANGTOOLS-1011] Empty XML anydata nodes cannot be normalized Created: 25/Jul/19  Updated: 23/Feb/23  Resolved: 21/Feb/23

Status: Resolved
Project: yangtools
Component/s: codecs
Affects Version/s: 3.0.3
Fix Version/s: 11.0.0, 8.0.10, 9.0.7, 10.0.5

Type: Bug Priority: Medium
Reporter: Robert Varga Assignee: Ruslan Kashapov
Resolution: Done Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The following exception is thrown when an attempt to normalize a DOMSourceAnydata which does not contain any data

java.lang.IllegalStateException: Attributes can be extracted only from START_ELEMENT.
    at com.google.common.base.Preconditions.checkState(Preconditions.java:508)
    at org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream.getElementAttributes(XmlParserStream.java:301)
    at org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream.read(XmlParserStream.java:387)
    at org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream.parse(XmlParserStream.java:270)
    at org.opendaylight.yangtools.yang.data.codec.xml.DOMSourceAnydata.writeTo(DOMSourceAnydata.java:65)
    at org.opendaylight.yangtools.yang.data.impl.schema.AbstractNormalizableAnydata.normalizeTo(AbstractNormalizableAnydata.java:36)


 Comments   
Comment by Robert Varga [ 25/Jul/19 ]

The problem is that the normalization skips the first event in an attempt to skip the outer wrapper element. This leads to moving from START_DOCUMENT to START_ELEMENT, which is okay, except XmlParserStream.read() also performs nextTag(), which moves it to END_ELEMENT – and it expects to land at the START_ELEMENT.

This is a bit of a pickle, as we need to reconcile who deals with which element when coming in from a regular document vs. an anydata document.

Generated at Wed Feb 07 20:54:56 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.