aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2013-11-22 11:50:08 (EST)
committerJohn Ross2013-11-22 13:10:30 (EST)
commitd4275eb585156ed02f52d186a0cfb9eb8fa86819 (patch)
tree307136fa30eba7d79a80a65e254c23739f6014a1
parent5bdaa4451d78c0dab69157169c53ee3ab40996c7 (diff)
downloadrt.equinox.bundles-d4275eb585156ed02f52d186a0cfb9eb8fa86819.zip
rt.equinox.bundles-d4275eb585156ed02f52d186a0cfb9eb8fa86819.tar.gz
rt.equinox.bundles-d4275eb585156ed02f52d186a0cfb9eb8fa86819.tar.bz2
Bug 421487 - Check for null (again) when unwinding the thread local coordination stack.I20131126-0800
The previous fix still had a small window of opportunity for an NPE to occur. Each call to peek results in orphaned coordination processing, so despite the initial check for coordinator.peek() != null, the subsequent calls to peek() could result in null if a coordination on the thread local stack became orphaned during that time.
-rw-r--r--bundles/org.eclipse.equinox.coordinator/src/org/eclipse/equinox/coordinator/CoordinationImpl.java11
1 files changed, 7 insertions, 4 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 1a241b9..2ad246c 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
@@ -138,11 +138,14 @@ public class CoordinationImpl {
}
// Unwind the stack in case there are other coordinations higher
// up than this one. See bug 421487 for why peek() may be null.
- while (!(coordinator.peek() == null || coordinator.peek().equals(referent))) {
+ for (Coordination peeked = coordinator.peek(); !(peeked == null || referent.equals(peeked)); peeked = coordinator.peek()) {
try {
- coordinator.peek().end();
- } catch (CoordinationException e) {
- coordinator.peek().fail(e);
+ peeked.end();
+ }
+ catch (CoordinationException e) {
+ peeked = coordinator.peek();
+ if (peeked != null)
+ peeked.fail(e);
}
}
// A coordination is removed from the thread local stack only when being ended.