Skip to content

Commit 16052d4

Browse files
committed
feedback
1 parent d608d2c commit 16052d4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/common/ProgressListenableActionFuture.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ private record PositionAndListener(long position, ActionListener<Long> listener)
3737

3838
/**
3939
* A consumer that accepts progress made by this {@link ProgressListenableActionFuture}. The consumer is called before listeners are
40-
* notified of the updated progress value in {@link #onProgress(long)}. The consumer can be called with out-of-order progress values.
40+
* notified of the updated progress value in {@link #onProgress(long)} if the value is less than the actual end. The consumer can be
41+
* called with out-of-order progress values.
4142
*/
4243
@Nullable
4344
private final LongConsumer progressConsumer;

x-pack/plugin/blob-cache/src/test/java/org/elasticsearch/blobcache/common/ProgressListenableActionFutureTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,12 @@ public void testLongConsumerCalledOnProgressUpdate() {
243243
var future = new ProgressListenableActionFuture(
244244
start,
245245
end,
246-
p -> assertThat("LongConsumer should not consumed the same value twice", consumed.add(p), equalTo(true))
246+
p -> assertThat("LongConsumer should not consumed the same value twice", consumed.add(p), equalTo(true))
247247
);
248248

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

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

273276
private static ProgressListenableActionFuture randomFuture() {

x-pack/plugin/blob-cache/src/test/java/org/elasticsearch/blobcache/common/SparseFileTrackerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ public void testCompletePointerUpdatesOnProgress() {
562562
tracker.getComplete(),
563563
equalTo(j + 1L)
564564
);
565+
assertThat(awaitingListener.isDone(), equalTo(true));
565566
latestUpdatedCompletePointer = tracker.getComplete();
566567
} else {
567568
assertThat(

0 commit comments

Comments
 (0)