Top Description Fields Constructors Methods
io.reactivex.plugins

public final Class RxJavaPlugins

extends Object
Class Inheritance
Imports
java.lang.Thread.UncaughtExceptionHandler, java.util.concurrent.*, org.reactivestreams.Subscriber, io.reactivex.*, io.reactivex.annotations.*, io.reactivex.exceptions.*, io.reactivex.flowables.ConnectableFlowable, io.reactivex.functions.*, io.reactivex.internal.functions.ObjectHelper, io.reactivex.internal.schedulers.*, io.reactivex.internal.util.ExceptionHelper, io.reactivex.observables.ConnectableObservable, io.reactivex.parallel.ParallelFlowable, io.reactivex.schedulers.Schedulers

Utility class to inject handlers to certain standard RxJava operations.

Field Summary

Modifier and TypeField and Description
pack-priv static volatile Consumer<? super Throwable>
pack-priv static volatile boolean
failNonBlockingScheduler

If true, attempting to run a blockingX operation on a (by default) computation or single scheduler will throw an IllegalStateException.

pack-priv static volatile boolean
lockdown

Prevents changing the plugins.

pack-priv static volatile BooleanSupplier
pack-priv static volatile Function<? super Completable, ? extends Completable>
pack-priv static volatile BiFunction<? super Completable, ? super CompletableObserver, ? extends CompletableObserver>
pack-priv static volatile Function<? super Scheduler, ? extends Scheduler>
pack-priv static volatile Function<? super ConnectableFlowable<T>, ? extends ConnectableFlowable<T>>
pack-priv static volatile Function<? super ConnectableObservable<T>, ? extends ConnectableObservable<T>>
pack-priv static volatile Function<? super Flowable<T>, ? extends Flowable<T>>
pack-priv static volatile BiFunction<? super Flowable<T>, ? super Subscriber<T>, ? extends Subscriber<T>>
pack-priv static volatile Function<? super Callable<Scheduler>, ? extends Scheduler>
pack-priv static volatile Function<? super Callable<Scheduler>, ? extends Scheduler>
pack-priv static volatile Function<? super Callable<Scheduler>, ? extends Scheduler>
pack-priv static volatile Function<? super Callable<Scheduler>, ? extends Scheduler>
pack-priv static volatile Function<? super Scheduler, ? extends Scheduler>
pack-priv static volatile Function<? super Maybe<T>, ? extends Maybe<T>>
pack-priv static volatile BiFunction<? super Maybe<T>, ? super MaybeObserver<T>, ? extends MaybeObserver<T>>
pack-priv static volatile Function<? super Scheduler, ? extends Scheduler>
pack-priv static volatile Function<? super Observable<T>, ? extends Observable<T>>
pack-priv static volatile BiFunction<? super Observable<T>, ? super Observer<T>, ? extends Observer<T>>
pack-priv static volatile Function<? super ParallelFlowable<T>, ? extends ParallelFlowable<T>>
pack-priv static volatile Function<? super Runnable, ? extends Runnable>
pack-priv static volatile Function<? super Single<T>, ? extends Single<T>>
pack-priv static volatile Function<? super Scheduler, ? extends Scheduler>
pack-priv static volatile BiFunction<? super Single<T>, ? super SingleObserver<T>, ? extends SingleObserver<T>>

Constructor Summary

AccessConstructor and Description
private
RxJavaPlugins()

Helper class, no instances.

Method Summary

Modifier and TypeMethod and Description
pack-priv static <
the input type
T
,
the output type
R
>
R

Returns:

the result of the function call
apply
(Function<T, R>
the function to call, not null (not verified)
f
,
T
the parameter value to the function
t
)

Wraps the call to the function in try-catch and propagates thrown checked exceptions as RuntimeException.

pack-priv static <
the first input type
T
,
the second input type
U
,
the output type
R
>
R

Returns:

the result of the function call
apply
(BiFunction<T, U, R>
the function to call, not null (not verified)
f
,
T
the first parameter value to the function
t
,
U
the second parameter value to the function
u
)

Wraps the call to the function in try-catch and propagates thrown checked exceptions as RuntimeException.

pack-priv static Scheduler

Returns:

the result of the function call, not null
applyRequireNonNull
(Function<? super Callable<Scheduler>, ? extends Scheduler>
the function to call, not null (not verified). Cannot return null
f
,
Callable<Scheduler>
the parameter value to the function
s
)

Wraps the call to the Scheduler creation function in try-catch and propagates thrown checked exceptions as RuntimeException and enforces that result is not null.

pack-priv static Scheduler

Returns:

the result of the callable call, not null
callRequireNonNull
(Callable<Scheduler>
the Callable which returns a Scheduler, not null (not verified). Cannot return null
s
)

Wraps the call to the Scheduler creation callable in try-catch and propagates thrown checked exceptions as RuntimeException and enforces that result is not null.

public static Scheduler

Returns:

the created Scheduler instance
createComputationScheduler
(ThreadFactory
thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
threadFactory
)

Create an instance of the default Scheduler used for Schedulers#computation() except using threadFactory for thread creation.

public static Scheduler

Returns:

the created Scheduler instance
createIoScheduler
(ThreadFactory
thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
threadFactory
)

Create an instance of the default Scheduler used for Schedulers#io() except using threadFactory for thread creation.

public static Scheduler

Returns:

the created Scheduler instance
createNewThreadScheduler
(ThreadFactory
thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
threadFactory
)

Create an instance of the default Scheduler used for Schedulers#newThread() except using threadFactory for thread creation.

public static Scheduler

Returns:

the created Scheduler instance
createSingleScheduler
(ThreadFactory
thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
threadFactory
)

Create an instance of the default Scheduler used for Schedulers#single() except using threadFactory for thread creation.

public static Function<? super Scheduler, ? extends Scheduler>

Returns:

the hook function, may be null
getComputationSchedulerHandler
()

Returns the current hook function.

public static Consumer<? super Throwable>

Returns:

the hook consumer, may be null
getErrorHandler
()

Returns the a hook consumer.

public static Function<? super Callable<Scheduler>, ? extends Scheduler>

Returns:

the hook function, may be null
getInitComputationSchedulerHandler
()

Returns the current hook function.

public static Function<? super Callable<Scheduler>, ? extends Scheduler>

Returns:

the hook function, may be null
getInitIoSchedulerHandler
()

Returns the current hook function.

public static Function<? super Callable<Scheduler>, ? extends Scheduler>

Returns:

the hook function, may be null
getInitNewThreadSchedulerHandler
()

Returns the current hook function.

public static Function<? super Callable<Scheduler>, ? extends Scheduler>

Returns:

the hook function, may be null
getInitSingleSchedulerHandler
()

Returns the current hook function.

public static Function<? super Scheduler, ? extends Scheduler>

Returns:

the hook function, may be null
getIoSchedulerHandler
()

Returns the current hook function.

public static Function<? super Scheduler, ? extends Scheduler>

Returns:

the hook function, may be null
getNewThreadSchedulerHandler
()

Returns the current hook function.

public static BooleanSupplier

Returns:

the current blocking handler or null if not specified
getOnBeforeBlocking
()

Returns the current blocking handler or null if no custom handler is set.

public static Function<? super Completable, ? extends Completable>

Returns:

the hook function, may be null
getOnCompletableAssembly
()

Returns the current hook function.

public static BiFunction<? super Completable, ? super CompletableObserver, ? extends CompletableObserver>

Returns:

the hook function, may be null
getOnCompletableSubscribe
()

Returns the current hook function.

public static Function<? super ConnectableFlowable<T>, ? extends ConnectableFlowable<T>>

Returns:

the hook function, may be null
getOnConnectableFlowableAssembly
()

Returns the current hook function.

public static Function<? super ConnectableObservable<T>, ? extends ConnectableObservable<T>>

Returns:

the hook function, may be null
getOnConnectableObservableAssembly
()

Returns the current hook function.

public static Function<? super Flowable<T>, ? extends Flowable<T>>

Returns:

the hook function, may be null
getOnFlowableAssembly
()

Returns the current hook function.

public static BiFunction<? super Flowable<T>, ? super Subscriber<T>, ? extends Subscriber<T>>

Returns:

the hook function, may be null
getOnFlowableSubscribe
()

Returns the current hook function.

public static Function<? super Maybe<T>, ? extends Maybe<T>>

Returns:

the hook function, may be null
getOnMaybeAssembly
()

Returns the current hook function.

public static BiFunction<? super Maybe<T>, ? super MaybeObserver<T>, ? extends MaybeObserver<T>>

Returns:

the hook function, may be null
getOnMaybeSubscribe
()

Returns the current hook function.

public static Function<? super Observable<T>, ? extends Observable<T>>

Returns:

the hook function, may be null
getOnObservableAssembly
()

Returns the current hook function.

public static BiFunction<? super Observable<T>, ? super Observer<T>, ? extends Observer<T>>

Returns:

the hook function, may be null
getOnObservableSubscribe
()

Returns the current hook function.

public static Function<? super ParallelFlowable<T>, ? extends ParallelFlowable<T>>

Returns:

the hook function, may be null
getOnParallelAssembly
()

Returns the current hook function.

public static Function<? super Single<T>, ? extends Single<T>>

Returns:

the hook function, may be null
getOnSingleAssembly
()

Returns the current hook function.

public static BiFunction<? super Single<T>, ? super SingleObserver<T>, ? extends SingleObserver<T>>

Returns:

the hook function, may be null
getOnSingleSubscribe
()

Returns the current hook function.

public static Function<? super Runnable, ? extends Runnable>

Returns:

the hook function, may be null
getScheduleHandler
()

Returns the current hook function.

public static Function<? super Scheduler, ? extends Scheduler>

Returns:

the hook function, may be null
getSingleSchedulerHandler
()

Returns the current hook function.

public static Scheduler

Returns:

the value returned by the hook, not null
initComputationScheduler
(Callable<Scheduler>
a Callable which returns the hook's input value
defaultScheduler
)

Calls the associated hook function.

public static Scheduler

Returns:

the value returned by the hook, not null
initIoScheduler
(Callable<Scheduler>
a Callable which returns the hook's input value
defaultScheduler
)

Calls the associated hook function.

public static Scheduler

Returns:

the value returned by the hook, not null
initNewThreadScheduler
(Callable<Scheduler>
a Callable which returns the hook's input value
defaultScheduler
)

Calls the associated hook function.

public static Scheduler

Returns:

the value returned by the hook, not null
initSingleScheduler
(Callable<Scheduler>
a Callable which returns the hook's input value
defaultScheduler
)

Calls the associated hook function.

pack-priv static boolean

Returns:

true if the error should pass through, false if it may be wrapped into an UndeliverableException
isBug
(Throwable
the error to check
error
)

Checks if the given error is one of the already named bug cases that should pass through onError(Throwable) as is.

public static boolean

Returns:

true if the blockingX operators fail on a non-blocking scheduler
isFailOnNonBlockingScheduler
()

Returns true if the blockingX operators fail with an IllegalStateException on a non-blocking scheduler such as computation or single.

public static boolean

Returns:

true if the plugins were locked down
isLockdown
()

Returns true if the plugins were locked down.

public static void
lockdown()

Prevents changing the plugins from then on.

public static <
the value type
T
>
Maybe<T>

Returns:

the value returned by the hook
onAssembly
(Maybe<T>
the hook's input value
source
)

Calls the associated hook function.

public static <
the value type
T
>
Flowable<T>

Returns:

the value returned by the hook
onAssembly
(Flowable<T>
the hook's input value
source
)

Calls the associated hook function.

public static <
the value type
T
>
ConnectableFlowable<T>

Returns:

the value returned by the hook
onAssembly
(ConnectableFlowable<T>
the hook's input value
source
)

Calls the associated hook function.

public static <
the value type
T
>
Observable<T>

Returns:

the value returned by the hook
onAssembly
(Observable<T>
the hook's input value
source
)

Calls the associated hook function.

public static <
the value type
T
>
ConnectableObservable<T>

Returns:

the value returned by the hook
onAssembly
(ConnectableObservable<T>
the hook's input value
source
)

Calls the associated hook function.

public static <
the value type
T
>
Single<T>

Returns:

the value returned by the hook
onAssembly
(Single<T>
the hook's input value
source
)

Calls the associated hook function.

public static Completable

Returns:

the value returned by the hook
onAssembly
(Completable
the hook's input value
source
)

Calls the associated hook function.

public static <
the value type of the source
T
>
ParallelFlowable<T>

Returns:

the value returned by the hook
onAssembly
(ParallelFlowable<T>
the hook's input value
source
)

Calls the associated hook function.

public static boolean

Returns:

true if the blocking should be prevented
onBeforeBlocking
()

Called before an operator attempts a blocking operation such as awaiting a condition or signal and should return true to indicate the operator should not block but throw an IllegalArgumentException.

public static Scheduler

Returns:

the value returned by the hook
onComputationScheduler
(Scheduler
the hook's input value
defaultScheduler
)

Calls the associated hook function.

public static void
onError(Throwable
the error to report
error
)

Called when an undeliverable error occurs.

public static Scheduler

Returns:

the value returned by the hook
onIoScheduler
(Scheduler
the hook's input value
defaultScheduler
)

Calls the associated hook function.

public static Scheduler

Returns:

the value returned by the hook
onNewThreadScheduler
(Scheduler
the hook's input value
defaultScheduler
)

Calls the associated hook function.

public static Runnable

Returns:

the replacement runnable
onSchedule
(Runnable
the runnable instance
run
)

Called when a task is scheduled.

public static Scheduler

Returns:

the value returned by the hook
onSingleScheduler
(Scheduler
the hook's input value
defaultScheduler
)

Calls the associated hook function.

public static <
the value type
T
>
Subscriber<? super T>

Returns:

the value returned by the hook
onSubscribe
(Flowable<T>
the hook's input value
source
,
Subscriber<? super T>
the subscriber
subscriber
)

Calls the associated hook function.

public static <
the value type
T
>
Observer<? super T>

Returns:

the value returned by the hook
onSubscribe
(Observable<T>
the hook's input value
source
,
Observer<? super T>
the observer
observer
)

Calls the associated hook function.

public static <
the value type
T
>
SingleObserver<? super T>

Returns:

the value returned by the hook
onSubscribe
(Single<T>
the hook's input value
source
,
SingleObserver<? super T>
the observer
observer
)

Calls the associated hook function.

public static CompletableObserver

Returns:

the value returned by the hook
onSubscribe
(Completable
the hook's input value
source
,
CompletableObserver
the observer
observer
)

Calls the associated hook function.

public static <
the value type
T
>
MaybeObserver<? super T>

Returns:

the value returned by the hook
onSubscribe
(Maybe<T>
the hook's input value
source
,
MaybeObserver<? super T>
the subscriber
observer
)

Calls the associated hook function.

public static void
reset()

Removes all handlers and resets to default behavior.

public static void
setComputationSchedulerHandler(Function<? super Scheduler, ? extends Scheduler>
the hook function to set, null allowed
handler
)

Sets the specific hook function.

public static void
setErrorHandler(Consumer<? super Throwable>
the hook function to set, null allowed
handler
)

Sets the specific hook function.

public static void
setFailOnNonBlockingScheduler(boolean
enable or disable the feature
enable
)

Enables or disables the blockingX operators to fail with an IllegalStateException on a non-blocking scheduler such as computation or single.

public static void
setInitComputationSchedulerHandler(Function<? super Callable<Scheduler>, ? extends Scheduler>
the hook function to set, null allowed, but the function may not return null
handler
)

Sets the specific hook function.

public static void
setInitIoSchedulerHandler(Function<? super Callable<Scheduler>, ? extends Scheduler>
the hook function to set, null allowed, but the function may not return null
handler
)

Sets the specific hook function.

public static void
setInitNewThreadSchedulerHandler(Function<? super Callable<Scheduler>, ? extends Scheduler>
the hook function to set, null allowed, but the function may not return null
handler
)

Sets the specific hook function.

public static void
setInitSingleSchedulerHandler(Function<? super Callable<Scheduler>, ? extends Scheduler>
the hook function to set, null allowed, but the function may not return null
handler
)

Sets the specific hook function.

public static void
setIoSchedulerHandler(Function<? super Scheduler, ? extends Scheduler>
the hook function to set, null allowed
handler
)

Sets the specific hook function.

public static void
setNewThreadSchedulerHandler(Function<? super Scheduler, ? extends Scheduler>
the hook function to set, null allowed
handler
)

Sets the specific hook function.

public static void
setOnBeforeBlocking(BooleanSupplier
the handler to set, null resets to the default handler that always returns false
handler
)

Set the handler that is called when an operator attempts a blocking await; the handler should return true to prevent the blocking and to signal an IllegalStateException instead.

public static void
setOnCompletableAssembly(Function<? super Completable, ? extends Completable>
the hook function to set, null allowed
onCompletableAssembly
)

Sets the specific hook function.

public static void
setOnCompletableSubscribe(BiFunction<? super Completable, ? super CompletableObserver, ? extends CompletableObserver>
the hook function to set, null allowed
onCompletableSubscribe
)

Sets the specific hook function.

public static void
setOnConnectableFlowableAssembly(Function<? super ConnectableFlowable<T>, ? extends ConnectableFlowable<T>>
the hook function to set, null allowed
onConnectableFlowableAssembly
)

Sets the specific hook function.

public static void
setOnConnectableObservableAssembly(Function<? super ConnectableObservable<T>, ? extends ConnectableObservable<T>>
the hook function to set, null allowed
onConnectableObservableAssembly
)

Sets the specific hook function.

public static void
setOnFlowableAssembly(Function<? super Flowable<T>, ? extends Flowable<T>>
the hook function to set, null allowed
onFlowableAssembly
)

Sets the specific hook function.

public static void
setOnFlowableSubscribe(BiFunction<? super Flowable<T>, ? super Subscriber<T>, ? extends Subscriber<T>>
the hook function to set, null allowed
onFlowableSubscribe
)

Sets the specific hook function.

public static void
setOnMaybeAssembly(Function<? super Maybe<T>, ? extends Maybe<T>>
the hook function to set, null allowed
onMaybeAssembly
)

Sets the specific hook function.

public static void
setOnMaybeSubscribe(BiFunction<? super Maybe<T>, MaybeObserver<T>, ? extends MaybeObserver<T>>
the hook function to set, null allowed
onMaybeSubscribe
)

Sets the specific hook function.

public static void
setOnObservableAssembly(Function<? super Observable<T>, ? extends Observable<T>>
the hook function to set, null allowed
onObservableAssembly
)

Sets the specific hook function.

public static void
setOnObservableSubscribe(BiFunction<? super Observable<T>, ? super Observer<T>, ? extends Observer<T>>
the hook function to set, null allowed
onObservableSubscribe
)

Sets the specific hook function.

public static void
setOnParallelAssembly(Function<? super ParallelFlowable<T>, ? extends ParallelFlowable<T>>
the hook function to set, null allowed
handler
)

Sets the specific hook function.

public static void
setOnSingleAssembly(Function<? super Single<T>, ? extends Single<T>>
the hook function to set, null allowed
onSingleAssembly
)

Sets the specific hook function.

public static void
setOnSingleSubscribe(BiFunction<? super Single<T>, ? super SingleObserver<T>, ? extends SingleObserver<T>>
the hook function to set, null allowed
onSingleSubscribe
)

Sets the specific hook function.

public static void
setScheduleHandler(Function<? super Runnable, ? extends Runnable>
the hook function to set, null allowed
handler
)

Sets the specific hook function.

public static void
setSingleSchedulerHandler(Function<? super Scheduler, ? extends Scheduler>
the hook function to set, null allowed
handler
)

Sets the specific hook function.

pack-priv static void
pack-priv static void
unlock()

Revokes the lockdown, only for testing purposes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait