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:32 UTC

[incubator-daffodil] branch revert-402-daffodil-2374-changedVariablesStack_nilled created (now 3ce9f18)

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

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


      at 3ce9f18  Revert "Fix variables getting reset incorrectly"

This branch includes the following new commits:

     new 703412a  Revert "Added comment about PState.Mark's"
     new 3ce9f18  Revert "Fix variables getting reset incorrectly"

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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

Posted by ja...@apache.org.
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") }
 


[incubator-daffodil] 01/02: Revert "Added comment about PState.Mark's"

Posted by ja...@apache.org.
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 703412a35edddc4ca35958a14f0b1993afa01b22
Author: jadams-tresys <30...@users.noreply.github.com>
AuthorDate: Fri Jul 31 10:50:25 2020 -0400

    Revert "Added comment about PState.Mark's"
    
    This reverts commit 05d430d2b6f9c9c8c654f08a96d08ca630d0a5b6.
---
 .../main/scala/org/apache/daffodil/processors/parsers/PState.scala   | 5 +----
 1 file changed, 1 insertion(+), 4 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 8b3d8d7..6cf5d64 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
@@ -169,10 +169,7 @@ final class PState private (
   /**
    * This stack tracks variables that have changed within the current point of
    * uncertainty. This tracking is necessary to revert changes made to variables
-   * when the parser needs to backtrack. This stack needs to be pushed when a
-   * new mark is created and popped when it is discarded or reset. It is
-   * necessary for every mark to either be discarded or reset to inorder for
-   * this stack to funciton correctly.
+   * when the parser needs to backtrack.
    */
   private val changedVariablesStack = new MStackOf[mutable.MutableList[GlobalQName]]()
   changedVariablesStack.push(mutable.MutableList[GlobalQName]())