Repository: ode
Updated Branches:
  refs/heads/master 592e617cd -> 3734f4b87


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/760b379e
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/760b379e
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/760b379e

Branch: refs/heads/master
Commit: 760b379e0d61c3ce1ba650876df05892d9c5c531
Parents: 592e617
Author: sathwik <[email protected]>
Authored: Sun Jul 16 22:31:29 2017 +0530
Committer: sathwik <[email protected]>
Committed: Sun Jul 16 22:31:29 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/760b379e/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 7e537a2..b75b2f2 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;
   }
 
 }

Reply via email to