Skip to content

Commit ca49826

Browse files
committed
chore: we java now
1 parent 025c6ef commit ca49826

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

templates/java/api.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import java.util.function.IntUnaryOperator;
2020

2121
import java.time.Duration;
2222
import java.util.EnumSet;
23+
import java.util.Iterator;
2324
import java.util.Random;
2425
import java.util.Collections;
2526
import java.util.ArrayList;

templates/java/api_helpers.mustache

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)