Skip to content

Commit

Permalink
Avoid race condition in test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Sep 16, 2024
1 parent cd364fc commit 8b40e47
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void exceptionsFromInvalidConfigurationAreNotSwallowed() {
@Test
@Timeout(5)
void defersTasksWithIncompatibleLocks() throws Exception {
var configuration = new DefaultParallelExecutionConfiguration(2, 2, 3, 1, 1, __ -> true);
var configuration = new DefaultParallelExecutionConfiguration(2, 2, 2, 2, 1, __ -> true);

var lockManager = new LockManager();
var globalReadLock = lockManager.getLockForResource(GLOBAL_READ);
Expand All @@ -77,10 +77,14 @@ void defersTasksWithIncompatibleLocks() throws Exception {
threadNamesByTaskIdentifier.put(t.identifier(), Thread.currentThread().getName());
var leafTask1 = new DummyTestTask("leafTask1", nopLock, t1 -> {
threadNamesByTaskIdentifier.put(t1.identifier(), Thread.currentThread().getName());
pool.new ExclusiveTask(isolatedTask).fork();
bothLeafTasksAreRunning.countDown();
bothLeafTasksAreRunning.await();
pool.new ExclusiveTask(isolatedTask).fork();
deferred.await();
try {
deferred.await();
} catch (InterruptedException e) {
System.out.println("Interrupted while waiting for task to be deferred");
}
});
var leafTask2 = new DummyTestTask("leafTask2", nopLock, t2 -> {
threadNamesByTaskIdentifier.put(t2.identifier(), Thread.currentThread().getName());
Expand Down

0 comments on commit 8b40e47

Please sign in to comment.