commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject commons-scxml git commit: SCXML-275 <content> expression evaluation must fallback to empty string on error, see SCXML specification 5.6.2
Date Sun, 17 Dec 2017 22:58:57 GMT
Repository: commons-scxml
Updated Branches:
  refs/heads/master 1cc51f55d -> a55b13b7a


SCXML-275 <content> expression evaluation must fallback to empty string on error, see
SCXML specification 5.6.2


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

Branch: refs/heads/master
Commit: a55b13b7a0aa77d3e194563126f22db057873142
Parents: 1cc51f5
Author: Ate Douma <ate@apache.org>
Authored: Sun Dec 17 23:52:45 2017 +0100
Committer: Ate Douma <ate@apache.org>
Committed: Sun Dec 17 23:52:45 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/scxml2/model/Final.java | 13 ++++++++++++-
 .../org/apache/commons/scxml2/model/Invoke.java     | 11 ++++++++++-
 .../java/org/apache/commons/scxml2/model/Send.java  | 16 +++++++++++++++-
 3 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a55b13b7/src/main/java/org/apache/commons/scxml2/model/Final.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Final.java b/src/main/java/org/apache/commons/scxml2/model/Final.java
index 28a8063..04aaa16 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Final.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Final.java
@@ -90,7 +90,18 @@ public class Final extends EnterableState {
                 Context ctx = exctx.getScInstance().getGlobalContext();
                 if (content != null) {
                     if (content.getExpr() != null) {
-                        result = eval.cloneData(eval.eval(ctx, content.getExpr()));
+                        Object evalResult = null;
+                        try {
+                            evalResult = eval.eval(ctx, content.getExpr());
+                        } catch (SCXMLExpressionException e) {
+                            exctx.getInternalIOProcessor().addEvent(new EventBuilder(TriggerEvent.ERROR_EXECUTION,
+                                    TriggerEvent.ERROR_EVENT).build());
+                            exctx.getErrorReporter().onError(ErrorConstants.EXPRESSION_ERROR,
+                                    "Failed to evaluate <donedata> <content>
expression due to error: "+ e.getMessage()
+                                            + ", Using empty value instead.", getParent());
+                            evalResult = "";
+                        }
+                        result = eval.cloneData(evalResult);
                     } else if (content.getValue() != null) {
                         result = content.getValue();
                     }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a55b13b7/src/main/java/org/apache/commons/scxml2/model/Invoke.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Invoke.java b/src/main/java/org/apache/commons/scxml2/model/Invoke.java
index b7ccf37..a4a0d21 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Invoke.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Invoke.java
@@ -401,7 +401,16 @@ public class Invoke extends Action implements ContentContainer, ParamsContainer
             Object contentValue = null;
             if (src == null && content != null) {
                 if (content.getExpr() != null) {
-                    contentValue = eval.eval(ctx, content.getExpr());
+                    try {
+                        contentValue = eval.eval(ctx, content.getExpr());
+                    } catch (SCXMLExpressionException e) {
+                        exctx.getInternalIOProcessor().addEvent(new EventBuilder(TriggerEvent.ERROR_EXECUTION,
+                                TriggerEvent.ERROR_EVENT).build());
+                        exctx.getErrorReporter().onError(ErrorConstants.EXPRESSION_ERROR,
+                                "Failed to evaluate <invoke> <content> expression
due to error: "+ e.getMessage()
+                                        + ", Using empty value instead.", getParent());
+                        contentValue = "";
+                    }
                 } else if (content.getValue() != null) {
                     contentValue = content.getValue();
                 }

http://git-wip-us.apache.org/repos/asf/commons-scxml/blob/a55b13b7/src/main/java/org/apache/commons/scxml2/model/Send.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/scxml2/model/Send.java b/src/main/java/org/apache/commons/scxml2/model/Send.java
index 1ff8a7c..f38a0b4 100644
--- a/src/main/java/org/apache/commons/scxml2/model/Send.java
+++ b/src/main/java/org/apache/commons/scxml2/model/Send.java
@@ -24,9 +24,12 @@ import java.util.Map;
 import org.apache.commons.scxml2.ActionExecutionContext;
 import org.apache.commons.scxml2.Context;
 import org.apache.commons.scxml2.Evaluator;
+import org.apache.commons.scxml2.EventBuilder;
 import org.apache.commons.scxml2.SCXMLExpressionException;
 import org.apache.commons.scxml2.SCXMLIOProcessor;
 import org.apache.commons.scxml2.SCXMLSystemContext;
+import org.apache.commons.scxml2.TriggerEvent;
+import org.apache.commons.scxml2.semantics.ErrorConstants;
 
 /**
  * The class in this SCXML object model that corresponds to the
@@ -431,7 +434,18 @@ public class Send extends Action implements ContentContainer, ParamsContainer
{
         }
         else if (content != null) {
             if (content.getExpr() != null) {
-                payload = eval.cloneData(eval.eval(ctx, content.getExpr()));
+                Object evalResult = null;
+                try {
+                    evalResult = eval.eval(ctx, content.getExpr());
+                } catch (SCXMLExpressionException e) {
+                    exctx.getInternalIOProcessor().addEvent(new EventBuilder(TriggerEvent.ERROR_EXECUTION,
+                            TriggerEvent.ERROR_EVENT).build());
+                    exctx.getErrorReporter().onError(ErrorConstants.EXPRESSION_ERROR,
+                            "Failed to evaluate <send> <content> expression due
to error: "+ e.getMessage()
+                                    + ", Using empty value instead.", getParent());
+                    evalResult = "";
+                }
+                payload = eval.cloneData(evalResult);
             } else if (content.getValue() != null) {
                 payload = content.getValue();
             }


Mime
View raw message