Skip to content

Commit

Permalink
Fix race condition in test
Browse files Browse the repository at this point in the history
If the exector is really quick, it can run the test runnable before the array list is assigned to the `times` field.
  • Loading branch information
dmlloyd committed Oct 3, 2024
1 parent c2e1c42 commit 01e9401
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ public void testFixedDelayExecution() throws Exception {
@Test
public void testThatFixedDelayTerminatesTask() {
EnhancedQueueExecutor eqe = new EnhancedQueueExecutor.Builder().build();
final ArrayList<LocalDateTime> times = new ArrayList<>();
var r = new Runnable() {
final ScheduledFuture<?> future = eqe.scheduleWithFixedDelay(this, 0, 100, TimeUnit.MILLISECONDS);
final ArrayList<LocalDateTime> times = new ArrayList<>();
public void run() {
times.add(LocalDateTime.now());
if (times.size() >= 5) {
Expand Down

0 comments on commit 01e9401

Please sign in to comment.