Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DAFFODIL-2444

Path handling for expressions expects an infoset to exist, causing unhandled exceptions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.0.0
    • None
    • Diagnostics
    • None

    Description

      While enabling support for defineVariable's that have non-constant expressions, I ran into some error cases where the path handling code for expressions would throw NoSuchElement exceptions when trying to handle this case where we are trying to evaluate a path before the infoset even exists.

      I attempted to add some basic handling to the case I was running into, but that only lead to finding more issues where we were at least running into some Assert.invariant checks instead of exceptions, but there are probably a number of places that could use proper error handling in here if we want to handle situations like this where the infoset doesn't exist.

      Here is the stack trace for the test:
      [error] Test org.apache.daffodil.section07.variables.TestVariables.test_defineVariable_ref_infoset_err failed: java.util.NoSuchElementException: head of empty list, took 0.029 sec
      [error] at scala.collection.immutable.Nil$.head(List.scala:430)
      [error] at scala.collection.immutable.Nil$.head(List.scala:427)
      [error] at org.apache.daffodil.dpath.NamedStep.downwardStep$lzycompute(Expression.scala:1177)
      [error] at org.apache.daffodil.dpath.NamedStep.downwardStep(Expression.scala:1176)
      [error] at org.apache.daffodil.dpath.NamedStep.compiledDPath$lzycompute(Expression.scala:1167)
      [error] at org.apache.daffodil.dpath.NamedStep.compiledDPath(Expression.scala:1166)
      [error] at org.apache.daffodil.dpath.RelativePathExpression.$anonfun$compiledDPath$3(Expression.scala:828)
      [error] at scala.collection.immutable.List.map(List.scala:286)
      [error] at org.apache.daffodil.dpath.RelativePathExpression.compiledDPath$lzycompute(Expression.scala:827)
      [error] at org.apache.daffodil.dpath.RelativePathExpression.compiledDPath(Expression.scala:826)
      [error] at org.apache.daffodil.dpath.WholeExpression.compiledDPath$lzycompute(Expression.scala:650)
      [error] at org.apache.daffodil.dpath.WholeExpression.compiledDPath(Expression.scala:650)
      [error] at org.apache.daffodil.dpath.DFDLPathExpressionParser.compile(DFDLExpressionParser.scala:60)
      [error] at org.apache.daffodil.dsom.ExpressionCompiler.compileRealExpression(CompiledExpression.scala:219)
      [error] at org.apache.daffodil.dsom.ExpressionCompiler.compileExpression(CompiledExpression.scala:73)
      [error] at org.apache.daffodil.dsom.ExpressionCompiler.compileProperty(CompiledExpression.scala:116)
      [error] at org.apache.daffodil.dsom.DFDLDefineVariable.$anonfun$maybeDefaultValueExpr$1(DFDLDefineVariable.scala:73)
      [error] at scala.Option.map(Option.scala:230)
      [error] at org.apache.daffodil.dsom.DFDLDefineVariable.maybeDefaultValueExpr$lzycompute(DFDLDefineVariable.scala:72)
      [error] at org.apache.daffodil.dsom.DFDLDefineVariable.maybeDefaultValueExpr(DFDLDefineVariable.scala:69)
      [error] at org.apache.daffodil.dsom.DFDLDefineVariable.$anonfun$variableRuntimeData$1(DFDLDefineVariable.scala:86)
      [error] at org.apache.daffodil.dsom.DFDLDefineVariable.$anonfun$variableRuntimeData$1$adapted(DFDLDefineVariable.scala:86)
      [error] at org.apache.daffodil.processors.VariableRuntimeData.maybeDefaultValueExpr$lzycompute(RuntimeData.scala:966)
      [error] at org.apache.daffodil.processors.VariableRuntimeData.maybeDefaultValueExpr(RuntimeData.scala:966)
      [error] at org.apache.daffodil.processors.VariableRuntimeData.preSerialization(RuntimeData.scala:970)
      [error] at org.apache.daffodil.dsom.DFDLDefineVariable.$anonfun$new$1(DFDLDefineVariable.scala:35)
      [error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.liftedTree1$1(OOLAG.scala:669)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.valueAsAny$lzycompute(OOLAG.scala:667)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.valueAsAny(OOLAG.scala:664)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGHost.$anonfun$checkErrors$2(OOLAG.scala:414)
      [error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
      [error] at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGHost.checkErrors(OOLAG.scala:414)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGHost.checkErrors$(OOLAG.scala:400)
      [error] at org.apache.daffodil.dsom.SchemaComponentImpl.checkErrors(SchemaComponent.scala:35)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGHost.isError(OOLAG.scala:471)
      [error] at org.apache.daffodil.oolag.OOLAG$OOLAGHost.isError$(OOLAG.scala:470)
      [error] at org.apache.daffodil.dsom.SchemaSet.super$isError(SchemaSet.scala:483)
      [error] at org.apache.daffodil.dsom.SchemaSet.$anonfun$isError$2(SchemaSet.scala:483)
      [error] at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
      [error] at org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60)
      [error] at org.apache.daffodil.dsom.SchemaSet.isError(SchemaSet.scala:474)
      [error] at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:111)
      [error] at org.apache.daffodil.compiler.Compiler.org$apache$daffodil$compiler$Compiler$$compileSourceInternal(Compiler.scala:329)
      [error] at org.apache.daffodil.compiler.Compiler$.org$apache$daffodil$compiler$Compiler$$compileSourceSynchronizer(Compiler.scala:367)
      [error] at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:314)
      [error] at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.compileProcessor(DaffodilTDMLDFDLProcessor.scala:148)
      [error] at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.$anonfun$getProcessor$1(DaffodilTDMLDFDLProcessor.scala:169)
      [error] at org.apache.daffodil.tdml.SchemaCache.doCompile$lzycompute$1(SchemaCache.scala:95)
      [error] at org.apache.daffodil.tdml.SchemaCache.doCompile$1(SchemaCache.scala:95)
      [error] at org.apache.daffodil.tdml.SchemaCache.$anonfun$compileAndCache$1(SchemaCache.scala:108)
      [error] at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:86)
      [error] at org.apache.daffodil.tdml.SchemaCache$Cache.getOrElseUpdate(SchemaCache.scala:51)
      [error] at org.apache.daffodil.tdml.SchemaCache.compileAndCache(SchemaCache.scala:107)
      [error] at org.apache.daffodil.tdml.processor.TDMLDFDLProcessorFactory.getProcessor(DaffodilTDMLDFDLProcessor.scala:169)
      [error] at org.apache.daffodil.tdml.TestCase.run(TDMLRunner.scala:753)
      [error] at org.apache.daffodil.tdml.DFDLTestSuite.runOneTest(TDMLRunner.scala:387)
      [error] at org.apache.daffodil.tdml.Runner.runOneTest(RunnerFactory.scala:144)
      [error] at org.apache.daffodil.tdml.Runner.runOneTest(RunnerFactory.scala:150)
      [error] at org.apache.daffodil.section07.variables.TestVariables.test_defineVariable_ref_infoset_err(TestVariables.scala:71)

      Attachments

        Activity

          People

            Unassigned Unassigned
            jadams_tresys Josh Adams
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: