Skip to content

How to check type of Runnable inside the RxJavaPlugins onScheduleHandler #5733

@lukaszguz

Description

@lukaszguz

Hi
RxJava2 version: [2.1.6]
I have problem with RxJavaPlugins.onScheduleHandler.

public Disposable scheduleDirect(@NonNull Runnable run, long delay, @NonNull TimeUnit unit) {
        final Worker w = createWorker();
        final Runnable decoratedRun = RxJavaPlugins.onSchedule(run);
        DisposeTask task = new DisposeTask(decoratedRun, w);
        w.schedule(task, delay, unit);
        return task;
}

At the moment of changing thread pool Runnable is wrapped into DisposeTask so I can't check type of action inside scheduleHandler because DisposeTask is package scope.
Do you have any idea how to solve this problem without reflection? 😀

Here is my sample code: https://github.com/lukaszguz/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/rxjava2/SleuthRxJava2SchedulersHandler.java

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions