You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by at...@apache.org on 2016/01/02 21:51:39 UTC

commons-scxml git commit: SCXML-239: Groovy Context lose sync after serialize/deserialize of SCinstance - see: https://issues.apache.org/jira/browse/SCXML-239 for details - 'quick and dirty' fix: only use 'plain' SimpleContext for protected SCXMLSystemCo

Repository: commons-scxml
Updated Branches:
  refs/heads/master b6b783749 -> 29402ee97


SCXML-239: Groovy Context lose sync after serialize/deserialize of SCinstance
- see: https://issues.apache.org/jira/browse/SCXML-239 for details
- 'quick and dirty' fix: only use 'plain' SimpleContext for protected SCXMLSystemContext internal Context and (by default) for root Context
  This prevents custom variable (de)serialization logic as implemented in GroovyContext which causes 'disconnected' duplicate deserialization of the SCInstance Status object
- SCXML-247 will provide a more proper solution.


Project: http://git-wip-us.apache.org/repos/asf/commons-scxml/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-scxml/commit/29402ee9
Tree: http://git-wip-us.apache.org/repos/asf/commons-scxml/tree/29402ee9
Diff: http://git-wip-us.apache.org/repos/asf/commons-scxml/diff/29402ee9

Branch: refs/heads/master
Commit: 29402ee9790273d3957f70bfe9b281d3630d2f38
Parents: b6b7837
Author: Ate Douma <at...@apache.org>
Authored: Sat Jan 2 21:51:31 2016 +0100
Committer: Ate Douma <at...@apache.org>
Committed: Sat Jan 2 21:51:31 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/scxml2/SCInstance.java    | 10 ++++------
 .../org/apache/commons/scxml2/SCInstanceTest.java     | 14 --------------
 2 files changed, 4 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/29402ee9/src/main/java/org/apache/commons/scxml2/SCInstance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/SCInstance.java b/src/main/java/org/apache/commons/scxml2/SCInstance.java
index 73051ab..51fbbf5 100644
--- a/src/main/java/org/apache/commons/scxml2/SCInstance.java
+++ b/src/main/java/org/apache/commons/scxml2/SCInstance.java
@@ -363,9 +363,8 @@ public class SCInstance implements Serializable {
      * @return The root context.
      */
     public Context getRootContext() {
-        if (rootContext == null && evaluator != null) {
-            rootContext = Evaluator.NULL_DATA_MODEL.equals(evaluator.getSupportedDatamodel())
-                    ? new SimpleContext() : evaluator.newContext(null);
+        if (rootContext == null) {
+            rootContext = new SimpleContext();
         }
         return rootContext;
     }
@@ -380,7 +379,7 @@ public class SCInstance implements Serializable {
         getRootContext();
         if (systemContext != null) {
             // re-parent the system context
-            systemContext.setSystemContext(evaluator.newContext(rootContext));
+            systemContext.setSystemContext(new SimpleContext(rootContext));
         }
     }
 
@@ -394,8 +393,7 @@ public class SCInstance implements Serializable {
             // force initialization of rootContext
             getRootContext();
             if (rootContext != null) {
-                Context internalContext = Evaluator.NULL_DATA_MODEL.equals(evaluator.getSupportedDatamodel()) ?
-                        new SimpleContext() : evaluator.newContext(rootContext);
+                Context internalContext = new SimpleContext(rootContext);
                 systemContext = new SCXMLSystemContext(internalContext);
                 systemContext.getContext().set(SCXMLSystemContext.SESSIONID_KEY, UUID.randomUUID().toString());
                 String _name = stateMachine != null && stateMachine.getName() != null ? stateMachine.getName() : "";

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/29402ee9/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java b/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java
index b9a8ab6..cb02475 100644
--- a/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java
+++ b/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java
@@ -41,11 +41,6 @@ public class SCInstanceTest {
     }
     
     @Test
-    public void testGetRootContextNull() {
-        Assert.assertNull(instance.getRootContext());
-    }
-    
-    @Test
     public void testGetRootContext() {
         Context context = new SimpleContext();
         context.set("name", "value");
@@ -55,15 +50,6 @@ public class SCInstanceTest {
     }
     
     @Test
-    public void testGetRootContextEvaluator() throws Exception {
-        Evaluator evaluator = new JexlEvaluator();
-
-        executor.setEvaluator(evaluator);
-
-        Assert.assertTrue(instance.getRootContext() instanceof JexlContext);
-    }
-    
-    @Test
     public void testGetContext() {
         State target = new State();
         target.setId("1");