You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2013/08/30 00:17:27 UTC

[6/8] git commit: ODE-1002: orEach: When counters are negative or too large an InvalidExpressionValue fault must be thrown

ODE-1002: orEach: When counters are negative or too large an InvalidExpressionValue fault must be thrown


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

Branch: refs/heads/master
Commit: f901c37ecdce2a5578e29cc9413e1e65bc5539e3
Parents: 6ac86ca
Author: Tammo van Lessen <tv...@gmail.com>
Authored: Thu Aug 29 00:58:39 2013 +0200
Committer: Tammo van Lessen <tv...@gmail.com>
Committed: Thu Aug 29 23:52:30 2013 +0200

----------------------------------------------------------------------
 .../org/apache/ode/bpel/runtime/FOREACH.java    | 26 +++++++++++++++++---
 1 file changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/f901c37e/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java
----------------------------------------------------------------------
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java
index 2d99054..2627a1c 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/FOREACH.java
@@ -183,13 +183,31 @@ public class FOREACH extends ACTIVITY {
     private int evaluateCondition(OExpression condition)
             throws FaultException {
         try {
-            return getBpelRuntimeContext().getExpLangRuntime().
+            int cond = getBpelRuntimeContext().getExpLangRuntime().
                     evaluateAsNumber(condition, getEvaluationContext()).intValue();
+            
+            if (cond < 0) {
+                String msg = "ForEach counter was negative.";
+                __log.error(msg);
+                throw new FaultException(_oforEach.getOwner().constants.qnInvalidExpressionValue,msg);
+            }
+            
+            if (cond > Integer.MAX_VALUE) {
+                // FIXME: this is not entirely correct. ODE uses an signed integer but the
+                // value range for the counters are xs:unsignedInt, which do not fit in
+                // an integer. To keep byte code compatibility, we can't easily change the type
+                // of the fields. But we can probably live with the limitation to only
+                // support Integer.MAX_VALUE as a maximum instead of Integer.MAX_VALUE * 2 - 1.
+                String msg = "ForEach counter was too large.";
+                __log.error(msg);
+                throw new FaultException(_oforEach.getOwner().constants.qnInvalidExpressionValue,msg);
+            }
+
+            return cond;
         } catch (EvaluationException e) {
-            String msg;
-            msg = "ForEach counter value couldn't be evaluated as xs:unsignedInt.";
+            String msg = "ForEach counter value couldn't be evaluated as xs:unsignedInt.";
             __log.error(msg, e);
-            throw new FaultException(_oforEach.getOwner().constants.qnForEachCounterError,msg);
+            throw new FaultException(_oforEach.getOwner().constants.qnInvalidExpressionValue,msg);
         }
     }