googleapis / googleapis/google-cloud-java

[sdk-platform-java] Make ServerStream support spliterator()

Đang mở
#12,548 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
priority: p3 type: feature request
Ngôn ngữ chính
Java
Star
2.1k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
154

Mô tả

**Affects :** 1.58.2

`ServerStream` currently doesn't allow to call the `iterator()` method more than once. However some tool that consumes this iterable may want to check the characteristics. E.g the reactor project (webflux) which is now checking the characteristics of the iterator via `Iterable.spliterator()`. However this has the side effect of invoking the default method which invokes the `iterator()` method, thus setting the `consumed` boolean to `true`.

_FluxIterable_
```java
static boolean checkFinite(Iterable iterable) {
return iterable instanceof Collection || iterable.spliterator().hasCharacteristics(Spliterator.SIZED);
}
```

_Iterable_
```java
default Spliterator spliterator() {
return Spliterators.spliteratorUnknownSize(iterator(), 0);
}
```

While this can be worked around for this particular use case, it would be nice if the `ServerStream` provide basic support for spliterators.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.