Skip to content

Commit

Permalink
#1635 Fix LockAssert.makeAllAssertsPass(false) if no lock is held
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-krecan committed Dec 6, 2023
1 parent a92d285 commit 8d8f98a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public static void makeAllAssertsPass(boolean pass) {
if (pass) {
LockAssert.startLock(TEST_LOCK_NAME);
} else {
LockAssert.endLock();
if (LockAssert.alreadyLockedBy(TEST_LOCK_NAME)) {
LockAssert.endLock();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ void assertShouldNotFailIfConfiguredForTests() {
LockAssert.TestHelper.makeAllAssertsPass(false);
assertThatThrownBy(LockAssert::assertLocked).isInstanceOf(IllegalStateException.class);
}

@Test
void makeAllAssertsPassShouldNotFail() {
LockAssert.TestHelper.makeAllAssertsPass(false);
}
}

0 comments on commit 8d8f98a

Please sign in to comment.