public final class FlowPublisherAdapter
extends Object
implements AwaitableAdapter
Adapter for Publisher, the JDK's built-in Reactive Streams type. Enables:
await publisher — completes with the first onNext
value, then cancels the subscription. Completes with null if
the publisher signals onComplete without emitting.for await (item in publisher) — iterates over emitted values
with bounded backpressure (see DEFAULT_BATCH_SIZE).Conformance:
onNext(null) is treated as a protocol
violation and surfaced as a NullPointerException.onSubscribe after the first is cancelled.onError/onComplete are ignored.This adapter is registered as the lowest-priority built-in (after SPI-loaded adapters) so framework-specific adapters (Reactor, RxJava) take precedence for their concrete types.
| Modifiers | Name | Description |
|---|---|---|
static int |
DEFAULT_BATCH_SIZE |
Default request batch size for for await iteration. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
onComplete() |
|
public void |
onError(Throwable t) |
|
public void |
onNext(T item) |
|
public void |
onSubscribe(Flow.Subscription s) |
|
public boolean |
supportsAwaitable(Class<?> type) |
|
public boolean |
supportsIterable(Class<?> type) |
<T> |
public Awaitable<T> |
toAwaitable(Object source) |
<T> |
public Iterable<T> |
toIterable(Object source) |
Default request batch size for for await iteration. Chosen as a
compromise between throughput (larger = fewer request() calls)
and memory (larger = bigger in-flight buffer). Override per-call by
wrapping with a custom adapter if needed.