T- the type of the object to be eventually returned by the
@API(status=INTERNAL) public abstract class RetryWithRecovery<T> extends java.lang.Object
|Constructor and Description|
|Modifier and Type||Method and Description|
Method called by client which should implement the retry.
This is a helper function designed to cover most of the retry cases.
This methods check the type of exception thrown in the retry and depending on that it created a clear error message suggesting the possible cause of the issue.
public static <T> T executeAndRetry(RetryWithRecoveryBuilder<?> baseRetryBuilder, java.lang.String name, java.lang.String address, SupplierWithApiException<T> supplier)
RetryWithRecoveryBuilder.isNetworkOrMinorError(java.lang.Throwable)and refreshes the authSession if we get an unauthorized error.
T- the type of the object to be returned by the supplier.
RetryWithRecoveryBuildercontaining the base settings for the retry mechanism.
name- the name of the retry, can be any string but should specific to the function being retried.
supplier- the supplier returning the desired object which may fail with an exception.
com.symphony.bdk.http.api.ApiRuntimeException- if a non-handled
ApiExceptionthrown or if the max number of retries has been reached.
java.lang.RuntimeException- if any other exception thrown.
public abstract T execute() throws java.lang.Throwable
executeOnce()which executes one actual call to the supplier, runs potential recovery actions and potentially throws an exception.
java.lang.Throwable- in case the max number of retries exhausted or if any other exception thrown by the supplier or the recovery functions.
protected T executeOnce() throws java.lang.Throwable
supplier, catches the potential
Exception, return null if it satisfies
ignoreExceptionand runs the recovery functions if it matches its corresponding condition. This should be called by any implementation of
public static java.lang.String networkIssueMessageError(java.lang.Throwable t, java.lang.String address)
t- exception found
address- that the retry is trying to reach