Class SupplierHelper
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; interruption of the calling thread during that wait restores its interrupt status before propagation asSupplierException, while anInterruptedExceptionreported by the stage does not modify the calling thread's interrupt status.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; interruption of the calling thread during that wait restores its interrupt status before propagation asSupplierException, while anInterruptedExceptionreported by the stage does not modify the calling thread's interrupt status.- 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
-