Skip to content

Commit e47c41e

Browse files
committed
Update iterables.
1 parent 918368b commit e47c41e

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

kilo-client/src/main/java/org/httprpc/kilo/util/Iterables.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ private static class FilterIterator<T> implements Iterator<T> {
4141
public boolean hasNext() {
4242
if (hasNext == null) {
4343
hasNext = Boolean.FALSE;
44+
next = null;
4445

4546
while (iterator.hasNext()) {
46-
next = iterator.next();
47+
var element = iterator.next();
4748

48-
if (predicate.test(next)) {
49+
if (predicate.test(element)) {
4950
hasNext = Boolean.TRUE;
51+
next = element;
5052

5153
break;
5254
}

kilo-client/src/main/java/org/httprpc/kilo/util/concurrent/Pipe.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ public class Pipe<E> implements Iterable<E> {
4141
public boolean hasNext() {
4242
if (hasNext == null) {
4343
hasNext = Boolean.FALSE;
44+
next = null;
4445

45-
Object next;
46+
Object value;
4647
try {
4748
if (timeout == 0) {
48-
next = queue.take();
49+
value = queue.take();
4950
} else {
50-
next = queue.poll(timeout, TimeUnit.MILLISECONDS);
51+
value = queue.poll(timeout, TimeUnit.MILLISECONDS);
5152

52-
if (next == null) {
53+
if (value == null) {
5354
throw new TimeoutException("Poll timed out.");
5455
}
5556
}
5657
} catch (InterruptedException exception) {
5758
throw new RuntimeException(exception);
5859
}
5960

60-
if (next != TERMINATOR) {
61+
if (value != TERMINATOR) {
6162
hasNext = Boolean.TRUE;
62-
63-
this.next = (E)next;
63+
next = (E)value;
6464
}
6565
}
6666

0 commit comments

Comments
 (0)