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;
20
20
21
21
import java.time.Duration;
22
22
import java.util.EnumSet;
23
+ import java.util.Iterator;
23
24
import java.util.Random;
24
25
import java.util.Collections;
25
26
import java.util.ArrayList;
Original file line number Diff line number Diff line change @@ -44,12 +44,13 @@ public <T> List<WatchResponse> chunkedPush(
44
44
) {
45
45
List< WatchResponse> responses = new ArrayList<> ();
46
46
List< T> records = new ArrayList<> ();
47
- Int waitBatchSize = batchSize / 10;
47
+ int waitBatchSize = batchSize / 10;
48
48
if (waitBatchSize < 1) {
49
49
waitBatchSize = batchSize;
50
50
}
51
51
52
52
Iterator<T > it = objects.iterator();
53
+ T current = it.next();
53
54
54
55
while (true) {
55
56
if (records.size() == batchSize || ! it.hasNext()) {
@@ -65,7 +66,7 @@ public <T> List<WatchResponse> chunkedPush(
65
66
records.clear();
66
67
}
67
68
68
- records.add(it );
69
+ records.add(current );
69
70
70
71
if (waitForTasks && (responses.size() % waitBatchSize == 0 || !it.hasNext())) {
71
72
responses.subList(Math.max(responses.size() - waitBatchSize, 0), responses.size()).forEach(response -> {
@@ -94,6 +95,8 @@ public <T> List<WatchResponse> chunkedPush(
94
95
if (!it.hasNext()) {
95
96
break ;
96
97
}
98
+
99
+ current = it.next();
97
100
}
98
101
99
102
return responses;
You can’t perform that action at this time.
0 commit comments