public class ThrowableConstants extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BAD_INVOCATION
Value returned by
retryable to indicate that the passed Throwable
implies that retrying the operation that threw the Throwable with the same
arguments and the same expected return value would not be fruitful. |
static int |
BAD_OBJECT
Value returned by
retryable to indicate that the passed Throwable
implies that any further operations on the object that threw the Throwable would
not be fruitful. |
static int |
INDEFINITE
Value returned by
retryable to indicate that the passed Throwable
does not provide any new information on the state of the object that threw it. |
static int |
UNCATEGORIZED
Value returned by
retryable to indicate that the passed Throwable
was of a type that could not be classified. |
Constructor and Description |
---|
ThrowableConstants() |
Modifier and Type | Method and Description |
---|---|
static int |
retryable(Throwable t)
Attempt to classify the passed
Throwable in terms of what it implies about the
probability of success of future operations on the object that threw the exception. |
public static final int INDEFINITE
retryable
to indicate that the passed Throwable
does not provide any new information on the state of the object that threw it.public static final int BAD_INVOCATION
retryable
to indicate that the passed Throwable
implies that retrying the operation that threw the Throwable
with the same
arguments and the same expected return value would not be fruitful.public static final int BAD_OBJECT
retryable
to indicate that the passed Throwable
implies that any further operations on the object that threw the Throwable
would
not be fruitful.public static final int UNCATEGORIZED
retryable
to indicate that the passed Throwable
was of a type that could not be classified.public static int retryable(Throwable t)
Throwable
in terms of what it implies about the
probability of success of future operations on the object that threw the exception.
Note, the classification used by this method tends to assume the worst. For exceptions that
represent conditions that could get better by themselves but probably will not, it will
return BAD_OBJECT
or BAD_INVOCATION
instead of
INDEFINITE
. This makes it suitable for situations where it is better to give up,
fail early, and notify the next layer up that something is wrong than to continue silently
and retry. It is probably not a good choice for situations where the stakes are higher, like
deciding when to give up on a prepared transaction.
INDEFINITE
, BAD_INVOCATION
, or BAD_OBJECT
if
the exception is a RuntimeException
, Error
, or
java.rmi.RemoteException
depending on the details of the Throwable
.
Otherwise return UNCATEGORIZED
NullPointerException
- if the passed Throwable
is null
Copyright © GigaSpaces.