Skip to content

Commit

Permalink
[Performance #285] fix faulty test and ensure that the task is null a…
Browse files Browse the repository at this point in the history
…fter transferring out of throttled future
  • Loading branch information
lukaskabc committed Sep 12, 2024
1 parent d512acf commit 73818fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ protected ThrottledFuture<T> update(Supplier<T> task, @NonNull List<Consumer<T>>
/**
* Returns future with the task from the specified {@code throttledFuture}.
* If possible, transfers the task from this object to the specified {@code throttledFuture}.
* If the task was successfully transferred, this future is canceled.
*
* @param target the future to update
* @return target when current future is already being executed, was canceled or completed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ void transferUpdatesSecondFutureWithTask() {
verify(secondFuture).update(eq(firstTask), anyList());

// now verifies that the task in the first future is null
firstFuture.transfer(secondFuture);
verify(secondFuture).update(isNull(), anyList());
Object task = ReflectionTestUtils.getField(firstFuture, "task");
assertNull(task);
assertTrue(firstFuture.isCancelled());
}

@Test
Expand Down

0 comments on commit 73818fb

Please sign in to comment.