Skip to content

Commit

Permalink
Bail early if everything is as it should be
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 committed Dec 13, 2023
1 parent 4fb4609 commit d346c2c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions spock-core/src/main/java/org/spockframework/runtime/RunContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,20 @@ public void ensureInstalled() {
if (runContexts.isEmpty()) {
// we got a new thread that didn't inherit the original context, so just add us here
runContexts.add(this);
return;
}

if (runContexts.getFirst() == this) return; // everything is well

if (!runContexts.contains(this)) {
// something weird happened, and we got the got a separate RunContext hierarchy from what we'd expect
// maybe some thread re-use between runs
runContexts.clear();
runContexts.add(this);
} else {
if (!runContexts.contains(this)) {
// something weird happened, and we got the got a separate RunContext hierarchy from what we'd expect
// maybe some thread re-use between runs
runContexts.clear();
runContexts.add(this);
} else {
while (runContexts.getFirst() != this) {
// we got some residual child contexts that didn't get cleared after a thread spawn
runContexts.removeFirst();
}
while (runContexts.getFirst() != this) {
// we got some residual child contexts that didn't get cleared after a thread spawn
runContexts.removeFirst();
}
}
}
Expand Down

0 comments on commit d346c2c

Please sign in to comment.