Repository: ode Updated Branches: refs/heads/ode-1.3.x 3bdb03843 -> aaf3ac14f
ODE-1066: Credits to Igor and Vitaliy. Corrected compareTo method implementation of CompensationHandler. Project: http://git-wip-us.apache.org/repos/asf/ode/repo Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/c88eb51b Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/c88eb51b Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/c88eb51b Branch: refs/heads/ode-1.3.x Commit: c88eb51bb035c18767bb3ad70ffe8662c1c256d2 Parents: 3bdb038 Author: sathwik <[email protected]> Authored: Wed May 31 15:38:11 2017 +0530 Committer: sathwik <[email protected]> Committed: Wed May 31 15:38:50 2017 +0530 ---------------------------------------------------------------------- .../ode/bpel/runtime/CompensationHandler.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ode/blob/c88eb51b/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/CompensationHandler.java ---------------------------------------------------------------------- diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/CompensationHandler.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/CompensationHandler.java index 30333ae..554eec9 100644 --- a/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/CompensationHandler.java +++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/CompensationHandler.java @@ -66,7 +66,25 @@ public class CompensationHandler implements Serializable, Comparable<Compensatio } public int compareTo(CompensationHandler that) { - return (int) (that.scopeStartTime - this.scopeEndTime); + + if (that.equals(this)) { + return 0; + } + + //desc order on end time + int result = Long.compare(that.scopeEndTime, this.scopeEndTime); + + if (result == 0) { + //asc order on start time + result = Long.compare(this.scopeStartTime, that.scopeStartTime); + + //compare the hashcode incase both start and stop times are equal + if (result == 0) { + result = System.identityHashCode(this) > System.identityHashCode(that) ? 1 : -1; + } + } + + return result; } }
