Fix a bug in SegmentStages.unlinkFromSegmentContextsChain() -- didn't account for exceptional exit from nested context

This commit is contained in:
leventov
2015-12-23 16:29:08 +03:00
parent c448293788
commit 246eec8b77
@@ -350,7 +350,7 @@ public abstract class SegmentStages implements SegmentLock, LocksInterface {
public void checkNestedContextsQueryDifferentKeys(
LocksInterface innermostContextOnThisSegment) {
// TODO Spoon doesn't replace RHS instanceof occurances
// TODO Spoon doesn't replace RHS instanceof occurrences
if (innermostContextOnThisSegment.getClass() == this.getClass()) {
Data key = ((KeySearch) innermostContextOnThisSegment).inputKey;
if (Objects.equals(key, ((KeySearch) (Object) this).inputKey)) {
@@ -364,10 +364,12 @@ public abstract class SegmentStages implements SegmentLock, LocksInterface {
private void unlinkFromSegmentContextsChain() {
LocksInterface prevContext = rootContextLockedOnThisSegment;
while (true) {
assert prevContext.nextNode() != null;
if (prevContext.nextNode() == this)
LocksInterface nextNode = prevContext.nextNode();
// nextNode could be null, if this context failed initLocks() in
// checkNestedContextsQueryDifferentKeys()
if (nextNode == this || nextNode == null)
break;
prevContext = prevContext.nextNode();
prevContext = nextNode;
}
// i. e. structured unlocking
verifyInnermostContext();