Class AtomicThrowable

java.lang.Object
java.util.concurrent.atomic.AtomicReference<Throwable>
io.reactivex.rxjava3.internal.util.AtomicThrowable
All Implemented Interfaces:
Serializable

public final class AtomicThrowable extends AtomicReference<Throwable>
Atomic container for Throwables including combining and having a terminal state via ExceptionHelper.

Watch out for the leaked AtomicReference methods!

See Also:
  • Field Details

  • Constructor Details

    • AtomicThrowable

      public AtomicThrowable()
  • Method Details

    • tryAddThrowable

      public boolean tryAddThrowable(Throwable t)
      Atomically adds a Throwable to this container (combining with a previous Throwable is necessary).
      Parameters:
      t - the throwable to add
      Returns:
      true if successful, false if the container has been terminated
    • tryAddThrowableOrReport

      public boolean tryAddThrowableOrReport(Throwable t)
      Atomically adds a Throwable to this container (combining with a previous Throwable is necessary) or reports the error the global error handler and no changes are made.
      Parameters:
      t - the throwable to add
      Returns:
      true if successful, false if the container has been terminated
    • terminate

      public Throwable terminate()
      Atomically terminate the container and return the contents of the last non-terminal Throwable of it.
      Returns:
      the last Throwable
    • isTerminated

      public boolean isTerminated()
    • tryTerminateAndReport

      public void tryTerminateAndReport()
      Tries to terminate this atomic throwable (by swapping in the TERMINATED indicator) and calls RxJavaPlugins.onError(Throwable) if there was a non-null, non-indicator exception contained within before.
      Since:
      3.0.0
    • tryTerminateConsumer

      public void tryTerminateConsumer(org.reactivestreams.Subscriber<?> consumer)
      Tries to terminate this atomic throwable (by swapping in the TERMINATED indicator) and notifies the consumer if there was no error (onComplete) or there was a non-null, non-indicator exception contained before (onError). If there was a terminated indicator, the consumer is not signaled.
      Parameters:
      consumer - the consumer to notify
    • tryTerminateConsumer

      public void tryTerminateConsumer(Observer<?> consumer)
      Tries to terminate this atomic throwable (by swapping in the TERMINATED indicator) and notifies the consumer if there was no error (onComplete) or there was a non-null, non-indicator exception contained before (onError). If there was a terminated indicator, the consumer is not signaled.
      Parameters:
      consumer - the consumer to notify
    • tryTerminateConsumer

      public void tryTerminateConsumer(MaybeObserver<?> consumer)
      Tries to terminate this atomic throwable (by swapping in the TERMINATED indicator) and notifies the consumer if there was no error (onComplete) or there was a non-null, non-indicator exception contained before (onError). If there was a terminated indicator, the consumer is not signaled.
      Parameters:
      consumer - the consumer to notify
    • tryTerminateConsumer

      public void tryTerminateConsumer(SingleObserver<?> consumer)
      Tries to terminate this atomic throwable (by swapping in the TERMINATED indicator) and notifies the consumer if there was no error (onComplete) or there was a non-null, non-indicator exception contained before (onError). If there was a terminated indicator, the consumer is not signaled.
      Parameters:
      consumer - the consumer to notify
    • tryTerminateConsumer

      public void tryTerminateConsumer(CompletableObserver consumer)
      Tries to terminate this atomic throwable (by swapping in the TERMINATED indicator) and notifies the consumer if there was no error (onComplete) or there was a non-null, non-indicator exception contained before (onError). If there was a terminated indicator, the consumer is not signaled.
      Parameters:
      consumer - the consumer to notify
    • tryTerminateConsumer

      public void tryTerminateConsumer(Emitter<?> consumer)
      Tries to terminate this atomic throwable (by swapping in the TERMINATED indicator) and notifies the consumer if there was no error (onComplete) or there was a non-null, non-indicator exception contained before (onError). If there was a terminated indicator, the consumer is not signaled.
      Parameters:
      consumer - the consumer to notify