Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrx committed Jun 11, 2024
1 parent d608d2c commit 16052d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ private record PositionAndListener(long position, ActionListener<Long> listener)

/**
* A consumer that accepts progress made by this {@link ProgressListenableActionFuture}. The consumer is called before listeners are
* notified of the updated progress value in {@link #onProgress(long)}. The consumer can be called with out-of-order progress values.
* notified of the updated progress value in {@link #onProgress(long)} if the value is less than the actual end. The consumer can be
* called with out-of-order progress values.
*/
@Nullable
private final LongConsumer progressConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,12 @@ public void testLongConsumerCalledOnProgressUpdate() {
var future = new ProgressListenableActionFuture(
start,
end,
p -> assertThat("LongConsumer should not consumed the same value twice", consumed.add(p), equalTo(true))
p -> assertThat("LongConsumer should not consumed the same value twice", consumed.add(p), equalTo(true))
);

long position = start;
for (int i = 0; i < 25 && position < end - 1L; i++) {
int iters = randomIntBetween(10, 25);
for (int i = 0; i < iters && position < end - 1L; i++) {
var progress = randomLongBetween(position + 1L, end - 1L);

var listener = new PlainActionFuture<Long>();
Expand All @@ -268,6 +269,8 @@ public void testLongConsumerCalledOnProgressUpdate() {
assertThat(listener.isDone(), equalTo(true));
position = progress;
}
future.onProgress(end);
assertThat("LongConsumer is not called when progress is updated to the end", consumed.contains(end), equalTo(false));
}

private static ProgressListenableActionFuture randomFuture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ public void testCompletePointerUpdatesOnProgress() {
tracker.getComplete(),
equalTo(j + 1L)
);
assertThat(awaitingListener.isDone(), equalTo(true));
latestUpdatedCompletePointer = tracker.getComplete();
} else {
assertThat(
Expand Down

0 comments on commit 16052d4

Please sign in to comment.