java.lang.Object
io.helidon.faulttolerance.SupplierHelper
Helper to handle async suppliers that return
CompletionStage
.-
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimeException
Wraps aThrowable
in aRuntimeException
of typeSupplierException
if necessary.static <T> Supplier
<T> toSyncSupplier
(Supplier<? extends CompletionStage<T>> supplier, long timeout, TimeUnit unit) Maps a supplier returning aCompletionStage<T>
to a supplier returningT
by waiting on the stage to produce a value.static Throwable
Gets the underlying cause of aSupplierException
or 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 returningT
by 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 aThrowable
in aRuntimeException
of typeSupplierException
if necessary. Will never nestSupplierException
s.- Parameters:
t
- the throwable- Returns:
- the exception
-
unwrapThrowable
Gets the underlying cause of aSupplierException
or of aExecutionException
.- Parameters:
t
- the throwable- Returns:
- the cause or the same throwable
-