From 700a442d15ad226b6c762a6adc35507dab45ffcd Mon Sep 17 00:00:00 2001 From: John Ross Date: Mon, 7 Nov 2011 17:11:59 -0600 Subject: Bug 362232 - [coordinator] Add support for the new, mandatory orphaned coordination requirement. Modified CoordinationReferent.equals to return false if the object is not an instance of CoordinationReferent. In addition to the one listed below, this change required a couple of other changes to CoordinationImpl methods that were still returning CoordinationImpl instead of CoordinationReferent. Updated the while loop for unwinding the thread local stack in CoordinationImpl.end to compare apples to apples. --- .../src/org/eclipse/equinox/coordinator/CoordinationImpl.java | 9 ++++++--- .../org/eclipse/equinox/coordinator/CoordinationReferent.java | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java index 05236274b..9805cd1cd 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java @@ -126,7 +126,8 @@ public class CoordinationImpl implements Coordination { } // Unwind the stack in case there are other coordinations higher // up than this one. - while (!coordinator.peek().equals(this)) { + CoordinationReferent referent = new CoordinationReferent(this); + while (!coordinator.peek().equals(referent)) { try { coordinator.peek().end(); } catch (CoordinationException e) { @@ -255,7 +256,9 @@ public class CoordinationImpl implements Coordination { public synchronized Coordination getEnclosingCoordination() { coordinator.checkPermission(CoordinationPermission.ADMIN, name); - return enclosingCoordination; + if (enclosingCoordination == null) + return null; + return new CoordinationReferent(enclosingCoordination); } public Throwable getFailure() { @@ -315,7 +318,7 @@ public class CoordinationImpl implements Coordination { checkTerminated(); coordinator.push(this); } - return this; + return new CoordinationReferent(this); } synchronized Date getDeadline() { diff --git a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationReferent.java b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationReferent.java index 68b807d89..6f13e994d 100644 --- a/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationReferent.java +++ b/bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationReferent.java @@ -88,9 +88,11 @@ public class CoordinationReferent implements Coordination { @Override public boolean equals(Object object) { - if (object instanceof CoordinationReferent) - return coordination.equals(((CoordinationReferent)object).coordination); - return coordination.equals(object); + if (object == this) + return true; + if (!(object instanceof CoordinationReferent)) + return false; + return coordination.equals(((CoordinationReferent)object).coordination); } @Override -- cgit v1.2.3