You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by ja...@apache.org on 2020/07/31 14:50:34 UTC

[incubator-daffodil] 02/02: Revert "Fix variables getting reset incorrectly"

This is an automated email from the ASF dual-hosted git repository.

jadams pushed a commit to branch revert-402-daffodil-2374-changedVariablesStack_nilled
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git

commit 3ce9f1895aaa975482fe02021c48b72defc01086
Author: jadams-tresys <30...@users.noreply.github.com>
AuthorDate: Fri Jul 31 10:50:25 2020 -0400

    Revert "Fix variables getting reset incorrectly"
    
    This reverts commit b4d9e0fe1e2da4b55c875ddde58c5e105ed9798c.
---
 .../daffodil/processors/parsers/PState.scala       | 10 ++++--
 .../daffodil/section07/variables/variables.tdml    | 41 ----------------------
 .../section07/variables/TestVariables.scala        |  3 --
 3 files changed, 7 insertions(+), 47 deletions(-)

diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PState.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PState.scala
index 6cf5d64..1ce5002 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PState.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PState.scala
@@ -197,7 +197,6 @@ final class PState private (
 
   def mark(requestorID: String): PState.Mark = {
     // threadCheck()
-    changedVariablesStack.push(mutable.MutableList[GlobalQName]())
     val m = markPool.getFromPool(requestorID)
     m.captureFrom(this, requestorID)
     m
@@ -219,14 +218,19 @@ final class PState private (
       if (variable.isDefined)
         variable.get.reset
     }}
-    changedVariablesStack.pop
+    /* When parsing choices or unordered sequences it is necessary to clear the
+     * list at the top of the stack because it is possible for multiple
+     * PState.reset calls to occur withing the same point of uncertainty. If we
+     * do not clear the list, the changes made in failed branches of the choice
+     * will accumulate even though their effects have already been reset.
+     */
+    changedVariablesStack.top.clear
   }
 
   def discard(m: PState.Mark): Unit = {
     dataInputStream.discard(m.disMark)
     m.clear()
     markPool.returnToPool(m)
-    changedVariablesStack.pop
   }
 
   override def toString() = {
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml
index d7fc1c9..35eb691 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml
@@ -1754,45 +1754,4 @@
     </tdml:infoset>
   </tdml:parserTestCase>
 
-  <tdml:defineSchema name="variables_nilled_element">
-    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
-    <dfdl:format ref="ex:GeneralFormat"
-      nilKind="literalValue" nilValue="%ES;" useNilForDefault="no" nilValueDelimiterPolicy="none" />
-
-    <dfdl:defineVariable name="var1" type="xs:string" defaultValue="false" />
-    <xs:element name="root">
-      <xs:complexType>
-        <xs:sequence dfdl:separator=",">
-          <xs:element name="id" type="xs:unsignedShort" dfdl:lengthKind="explicit" dfdl:length="1">
-            <xs:annotation>
-              <xs:appinfo source="http://www.ogf.org/dfdl/">
-                <dfdl:setVariable ref="var1" value="true" />
-              </xs:appinfo>
-            </xs:annotation>
-          </xs:element>
-          <xs:element name="nillable_but_present" type="xs:string" nillable="true" dfdl:lengthKind="explicit" dfdl:length="4" />
-          <xs:choice dfdl:choiceDispatchKey="{ $ex:var1 }">
-            <xs:element name="var1_true" type="xs:string" dfdl:choiceBranchKey="true" dfdl:lengthKind="explicit" dfdl:length="7" />
-            <xs:element name="var1_false" type="xs:string" dfdl:choiceBranchKey="false" dfdl:lengthKind="explicit" dfdl:length="7" />
-          </xs:choice>
-        </xs:sequence>
-      </xs:complexType>
-    </xs:element>
-
-  </tdml:defineSchema>
-
-  <tdml:parserTestCase name="variables_nilled_element" root="root"
-    model="variables_nilled_element" description="Section 7 - setVariable - verify that variables aren't getting reset incorrectly - DAFFODIL-2374">
-    <tdml:document>1,test,is set?</tdml:document>
-    <tdml:infoset>
-      <tdml:dfdlInfoset>
-        <root>
-          <id>1</id>
-          <nillable_but_present>test</nillable_but_present>
-          <var1_true>is set?</var1_true>
-        </root>
-      </tdml:dfdlInfoset>
-    </tdml:infoset>
-  </tdml:parserTestCase>
-
 </tdml:testSuite>
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section07/variables/TestVariables.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section07/variables/TestVariables.scala
index 0a330af..79d62b8 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section07/variables/TestVariables.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section07/variables/TestVariables.scala
@@ -93,9 +93,6 @@ class TestVariables {
 
   @Test def test_unsignedIntVarCast(): Unit = { runner.runOneTest("unsignedIntVarCast") }
 
-  // DFDL-2374
-  @Test def test_variables_nilled_element(): Unit = { runner.runOneTest("variables_nilled_element") }
-
   // DFDL-2375
   //@Test def test_choiceBranchVariables(): Unit = { runner.runOneTest("choiceBranchVariables") }