java.lang.Object
io.helidon.faulttolerance.SupplierHelper
Helper to handle async suppliers that return
CompletionStage.-
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimeExceptionWraps aThrowablein aRuntimeExceptionof typeSupplierExceptionif necessary.static <T> Supplier<T> toSyncSupplier(Supplier<? extends CompletionStage<T>> supplier, long timeout, TimeUnit unit) Maps a supplier returning aCompletionStage<T>to a supplier returningTby waiting on the stage to produce a value.static ThrowableGets the underlying cause of aSupplierExceptionor of aExecutionException.
-
Method Details
-
toSyncSupplier
public static <T> Supplier<T> toSyncSupplier(Supplier<? extends CompletionStage<T>> supplier, long timeout, TimeUnit unit) Maps a supplier returning aCompletionStage<T>to a supplier returningTby waiting on the stage to produce a value.- Type Parameters:
T- type produced by supplier- Parameters:
supplier- the async suppliertimeout- time to waitunit- unit of time- Returns:
- the supplier
-
toRuntimeException
Wraps aThrowablein aRuntimeExceptionof typeSupplierExceptionif necessary. Will never nestSupplierExceptions.- Parameters:
t- the throwable- Returns:
- the exception
-
unwrapThrowable
Gets the underlying cause of aSupplierExceptionor of aExecutionException.- Parameters:
t- the throwable- Returns:
- the cause or the same throwable
-