Class AsyncNotSupported
The async and reactive SPI methods (e.g. ChatModel.doChatAsync, EmbeddingStore.searchAsync,
StreamingChatModel.doChat(ChatRequest)) ship a default body for providers that have not opted into
the non-blocking path. Rather than throwing AsyncNotSupportedException synchronously - which would
escape the method's own return-type contract, so whether it is safe depends on whether the call site happened to be
inside a future/publisher stage that launders the throw - the defaults signal the failure through their
return type's error channel: a failed CompletableFuture for future-returning methods, or an
immediately-failing Flow.Publisher for publisher-returning methods. The framework's offload-or-fail-loud
orchestration then observes it uniformly (via exceptionallyCompose/onError), regardless of context.
This does not change genuine implementations, nor the public entry points (chatAsync, embedAsync,
the AI-Service dispatch), which still convert their own synchronous validate(request) failures.
- Since:
- 1.20.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFuture<T> failedFuture(Class<?> implementationType, String methodName) static <T> CompletableFuture<T> failedFuture(String message) static <T> Flow.Publisher<T> failingPublisher(Class<?> implementationType, String methodName) static <T> Flow.Publisher<T> failingPublisher(String message)
-
Method Details
-
failedFuture
- Returns:
- an already-failed future carrying an
AsyncNotSupportedExceptionwhose message follows the convention"<methodName>() is not implemented by <implementationType>".
-
failedFuture
- Returns:
- an already-failed future carrying an
AsyncNotSupportedExceptionwith the given message (for defaults that provide their own, more detailed guidance).
-
failingPublisher
public static <T> Flow.Publisher<T> failingPublisher(Class<?> implementationType, String methodName) - Returns:
- a cold
Flow.Publisherthat, on subscribe, immediately signalsonErrorwith anAsyncNotSupportedExceptionwhose message follows the convention"<methodName>() is not implemented by <implementationType>".
-
failingPublisher
- Returns:
- a cold
Flow.Publisherthat, on subscribe, immediately signalsonErrorwith anAsyncNotSupportedExceptioncarrying the given message.
-