googleapis / googleapis/google-cloud-java

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

Offen
#12,548 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
priority: p3 type: feature request
Vorherrschende Sprache
Java
Sterne
2.1k
Forks
1.2k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
154

Beschreibung

**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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.