Class AtomicThrowable
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<Throwable>
-
- com.forgerock.rxjava3.intern.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AtomicThrowable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwable
terminate()
Atomically terminate the container and return the contents of the last non-terminal Throwable of it.boolean
tryAddThrowable(Throwable t)
Atomically adds a Throwable to this container (combining with a previous Throwable is necessary).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.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).-
Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
-
-
-
Method Detail
-
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
-
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
-
-