File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import java.util.function.IntUnaryOperator;
2020
2121import java.time.Duration;
2222import java.util.EnumSet;
23+ import java.util.Iterator;
2324import java.util.Random;
2425import java.util.Collections;
2526import java.util.ArrayList;
Original file line number Diff line number Diff line change @@ -44,12 +44,13 @@ public <T> List<WatchResponse> chunkedPush(
4444) {
4545 List< WatchResponse> responses = new ArrayList<> ();
4646 List< T> records = new ArrayList<> ();
47- Int waitBatchSize = batchSize / 10;
47+ int waitBatchSize = batchSize / 10;
4848 if (waitBatchSize < 1) {
4949 waitBatchSize = batchSize;
5050 }
5151
5252 Iterator<T > it = objects.iterator();
53+ T current = it.next();
5354
5455 while (true) {
5556 if (records.size() == batchSize || ! it.hasNext()) {
@@ -65,7 +66,7 @@ public <T> List<WatchResponse> chunkedPush(
6566 records.clear();
6667 }
6768
68- records.add(it );
69+ records.add(current );
6970
7071 if (waitForTasks && (responses.size() % waitBatchSize == 0 || !it.hasNext())) {
7172 responses.subList(Math.max(responses.size() - waitBatchSize, 0), responses.size()).forEach(response -> {
@@ -94,6 +95,8 @@ public <T> List<WatchResponse> chunkedPush(
9495 if (!it.hasNext()) {
9596 break ;
9697 }
98+
99+ current = it.next();
97100 }
98101
99102 return responses;
You can’t perform that action at this time.
0 commit comments