Class TransactionRetryResult<T>

java.lang.Object
com.pyranid.TransactionRetryResult<T>

@ThreadSafe public final class TransactionRetryResult<T> extends Object
Result of a successful Database.transactionWithRetry(RetryPolicy, ReturningTransactionalOperation) call.

Retry methods return this type instead of a bare Optional so callers can inspect failures that were recovered before the transaction eventually succeeded.

If retry attempts are exhausted, Pyranid throws the final DatabaseException instead of returning this type. Prior failed attempts are attached to the thrown exception as suppressed exceptions.

Since:
4.4.0
Author:
Mark Allen
  • Method Details

    • getValue

      public @NonNull Optional<T> getValue()
      Gets the value returned by the successful transaction attempt.
      Returns:
      successful transaction value, or empty if no value was returned
    • getFailures

      public @NonNull List<@NonNull DatabaseException> getFailures()
      Gets the failed attempts that were retried before the transaction eventually succeeded.

      Failures are returned in occurrence order. The returned list is immutable.

      Returns:
      failed attempts that were retried before success
    • getAttemptCount

      public @NonNull Integer getAttemptCount()
      Gets the number of transaction attempts, including the successful final attempt.
      Returns:
      attempt count
    • wasRetried

      public @NonNull Boolean wasRetried()
      Indicates whether at least one failed attempt was retried before success.
      Returns:
      true if the transaction succeeded after retrying, false otherwise