Steve Lawrence created DAFFODIL-3003:
----------------------------------------

             Summary: Unparsing streamed data without --stream causes 
NullPointerException
                 Key: DAFFODIL-3003
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-3003
             Project: Daffodil
          Issue Type: Bug
          Components: Back End, CLI
    Affects Versions: 3.10.0
            Reporter: Steve Lawrence


If you parse data using the --stream option, e.g.

{code:xml}
daffodil parse -s foo.dfdl.xsd --stream data.bin > data.xml
{code}

Then the resulting XML is a bunch of XML infosets separated by a NUL character. 
This NUL character is used by the CLI to delimit infosets when unparsing with 
something like

{code:xml}
daffodil unparse -s foo.dfdl.xsd --stream data.xml
{code}

But if you try to unaprse that file without the --stream option, e.g.

{code:xml}
daffodil unparse -s foo.dfdl.xsd data.xml
{code}

Then you get the following null pointer exception:

{code}
java.lang.NullPointerException
        at 
com.ctc.wstx.sr.InputElementStack.getCurrentNsCount(InputElementStack.java:1029)
        at 
com.ctc.wstx.sr.BasicStreamReader.getNamespaceCount(BasicStreamReader.java:807)
        at 
org.codehaus.stax2.ri.evt.EndElementEventImpl.<init>(EndElementEventImpl.java:35)
        at 
com.ctc.wstx.evt.DefaultEventAllocator.allocate(DefaultEventAllocator.java:159)
        at 
org.apache.daffodil.runtime1.infoset.XMLTextInfosetInputter.liftedTree2$1(XMLTextInfosetInputter.scala:406)
        at 
org.apache.daffodil.runtime1.infoset.XMLTextInfosetInputter.nextTagOrEndDocument(XMLTextInfosetInputter.scala:400)
        at 
org.apache.daffodil.runtime1.infoset.XMLTextInfosetInputter.next(XMLTextInfosetInputter.scala:381)
        at 
org.apache.daffodil.runtime1.infoset.InfosetInputter.reallyFill(InfosetInputter.scala:302)
        at 
org.apache.daffodil.runtime1.infoset.InfosetInputter.fill(InfosetInputter.scala:291)
        at 
org.apache.daffodil.lib.util.CursorImplMixin.doAdvance(Cursor.scala:198)
        at 
org.apache.daffodil.lib.util.CursorImplMixin.advance(Cursor.scala:158)
        at 
org.apache.daffodil.lib.util.CursorImplMixin.advance$(Cursor.scala:155)
        at 
org.apache.daffodil.runtime1.infoset.InfosetInputter.advance(InfosetInputter.scala:82)
        at 
org.apache.daffodil.runtime1.processors.unparsers.UStateMain.advance(UState.scala:606)
        at org.apache.daffodil.lib.util.Cursor.advanceMaybe(Cursor.scala:107)
        at org.apache.daffodil.lib.util.Cursor.advanceMaybe$(Cursor.scala:106)
        at 
org.apache.daffodil.runtime1.processors.unparsers.UState.advanceMaybe(UState.scala:72)
        at 
org.apache.daffodil.runtime1.processors.DataProcessor.doUnparse(DataProcessor.scala:669)
        at 
org.apache.daffodil.runtime1.processors.DataProcessor.unparse(DataProcessor.scala:557)
        at 
org.apache.daffodil.runtime1.processors.DataProcessor.unparse(DataProcessor.scala:541)
        at 
org.apache.daffodil.cli.InfosetHandler.unparseWithInfosetInputter(InfosetTypes.scala:219)
        at 
org.apache.daffodil.cli.InfosetHandler.unparseWithInfosetInputter$(InfosetTypes.scala:215)
        at 
org.apache.daffodil.cli.XMLTextInfosetHandler.unparseWithInfosetInputter(InfosetTypes.scala:286)
        at 
org.apache.daffodil.cli.XMLTextInfosetHandler.unparse(InfosetTypes.scala:300)
        at 
org.apache.daffodil.cli.Main.$anonfun$runIgnoreExceptions$31(Main.scala:1609)
        at org.apache.daffodil.lib.util.Timer$.getTimeResult(Timer.scala:78)
        at org.apache.daffodil.lib.util.Timer$.getResult(Timer.scala:37)
        at org.apache.daffodil.cli.Main.runIgnoreExceptions(Main.scala:1609)
        at org.apache.daffodil.cli.Main.run(Main.scala:2001)
        at org.apache.daffodil.cli.Main$.main(Main.scala:916)
        at org.apache.daffodil.cli.Main.main(Main.scala)
{code}

An error is correct since this infoset is invalid, but we should get a better 
diagnostics that says the input XML is invalid, and not an exception
The XMLTextInfosetInputter shoudl be able to detect this i



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to