Skip to content

Commit

Permalink
Ensure actual rejections occur
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveCTurner committed Jan 3, 2023
1 parent 0acd2f0 commit 0fc9484
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public void testFailsTasksOnRejectionOrShutdown() throws Exception {
final var totalPermits = between(1, maxThreads * 2);
final var permits = new Semaphore(totalPermits);
final var taskCompleted = new CountDownLatch(between(1, maxThreads * 2));
final var rejectionCountDown = new CountDownLatch(between(1, maxThreads * 2));

final var spawnThread = new Thread(() -> {
try {
Expand All @@ -197,7 +198,7 @@ public void testFailsTasksOnRejectionOrShutdown() throws Exception {
taskRunner.enqueueTask(new TestTask(taskCompleted::countDown, getRandomPriority()) {
@Override
public void onRejection(Exception e) {
// ok
rejectionCountDown.countDown();
}

@Override
Expand All @@ -214,6 +215,7 @@ public void onAfter() {
assertTrue(taskCompleted.await(10, TimeUnit.SECONDS));
executor.shutdown();
assertTrue(executor.awaitTermination(30, TimeUnit.SECONDS));
assertTrue(rejectionCountDown.await(10, TimeUnit.SECONDS));
spawnThread.interrupt();
spawnThread.join();
assertThat(taskRunner.runningTasks(), equalTo(0));
Expand Down

0 comments on commit 0fc9484

Please sign in to comment.