diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHook.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHook.java index aa8769f6d..f164de280 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHook.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHook.java @@ -5,14 +5,16 @@ import org.apache.commons.logging.LogFactory; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.TraceKeys; import org.springframework.cloud.sleuth.Tracer; + import rx.functions.Action0; import rx.plugins.RxJavaErrorHandler; import rx.plugins.RxJavaObservableExecutionHook; +import rx.plugins.RxJavaPlugins; import rx.plugins.RxJavaSchedulersHook; import rx.plugins.SleuthRxJavaPlugins; /** - * {@link RxJavaSchedulersHook} that wraps a {@link Action0} into its tracing + * {@link RxJavaSchedulersHook} that wraps an {@link Action0} into its tracing * representation. * * @author Shivang Shah @@ -31,18 +33,18 @@ class SleuthRxJavaSchedulersHook extends RxJavaSchedulersHook { this.tracer = tracer; this.traceKeys = traceKeys; try { - this.delegate = SleuthRxJavaPlugins.getInstance().getSchedulersHook(); + this.delegate = RxJavaPlugins.getInstance().getSchedulersHook(); if (this.delegate instanceof SleuthRxJavaSchedulersHook) { return; } - RxJavaErrorHandler errorHandler = SleuthRxJavaPlugins.getInstance().getErrorHandler(); + RxJavaErrorHandler errorHandler = RxJavaPlugins.getInstance().getErrorHandler(); RxJavaObservableExecutionHook observableExecutionHook - = SleuthRxJavaPlugins.getInstance().getObservableExecutionHook(); + = RxJavaPlugins.getInstance().getObservableExecutionHook(); logCurrentStateOfRxJavaPlugins(errorHandler, observableExecutionHook); SleuthRxJavaPlugins.resetPlugins(); - SleuthRxJavaPlugins.getInstance().registerSchedulersHook(this); - SleuthRxJavaPlugins.getInstance().registerErrorHandler(errorHandler); - SleuthRxJavaPlugins.getInstance().registerObservableExecutionHook(observableExecutionHook); + RxJavaPlugins.getInstance().registerSchedulersHook(this); + RxJavaPlugins.getInstance().registerErrorHandler(errorHandler); + RxJavaPlugins.getInstance().registerObservableExecutionHook(observableExecutionHook); } catch (Exception e) { log.error("Failed to register Sleuth RxJava SchedulersHook", e); } diff --git a/spring-cloud-sleuth-core/src/main/java/rx/plugins/SleuthRxJavaPlugins.java b/spring-cloud-sleuth-core/src/main/java/rx/plugins/SleuthRxJavaPlugins.java index 07950497c..0e746eb04 100644 --- a/spring-cloud-sleuth-core/src/main/java/rx/plugins/SleuthRxJavaPlugins.java +++ b/spring-cloud-sleuth-core/src/main/java/rx/plugins/SleuthRxJavaPlugins.java @@ -1,21 +1,19 @@ package rx.plugins; /** - * {@link RxJavaPlugins} helper class to access the package scope method - * of {@link RxJavaPlugins#reset()}. Will disappear once this gets closed + * {@link RxJavaPlugins} helper class to access the package scope method of + * {@link RxJavaPlugins#reset()}. + * + * @deprecated Will disappear once this gets closed * https://github.com/ReactiveX/RxJava/issues/2297 * * @author Shivang Shah - * @since 1.0.0 */ @Deprecated -public class SleuthRxJavaPlugins extends RxJavaPlugins { - - SleuthRxJavaPlugins() { - super(); - } +public class SleuthRxJavaPlugins { public static void resetPlugins() { - getInstance().reset(); + RxJavaPlugins.getInstance().reset(); } + } diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHookTest.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHookTests.java similarity index 76% rename from spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHookTest.java rename to spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHookTests.java index 6f13eea1b..4d30ba702 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHookTest.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rxjava/SleuthRxJavaSchedulersHookTests.java @@ -1,5 +1,7 @@ package org.springframework.cloud.sleuth.instrument.rxjava; +import static org.assertj.core.api.BDDAssertions.then; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -12,17 +14,16 @@ import org.springframework.cloud.sleuth.Tracer; import rx.functions.Action0; import rx.plugins.RxJavaErrorHandler; import rx.plugins.RxJavaObservableExecutionHook; +import rx.plugins.RxJavaPlugins; import rx.plugins.RxJavaSchedulersHook; import rx.plugins.SleuthRxJavaPlugins; -import static org.assertj.core.api.BDDAssertions.then; - /** * * @author Shivang Shah */ @RunWith(MockitoJUnitRunner.class) -public class SleuthRxJavaSchedulersHookTest { +public class SleuthRxJavaSchedulersHookTests { @Mock Tracer tracer; @@ -39,16 +40,16 @@ public class SleuthRxJavaSchedulersHookTest { @Test public void should_not_override_existing_custom_hooks() { - SleuthRxJavaPlugins.getInstance().registerErrorHandler(new MyRxJavaErrorHandler()); - SleuthRxJavaPlugins.getInstance().registerObservableExecutionHook(new MyRxJavaObservableExecutionHook()); + RxJavaPlugins.getInstance().registerErrorHandler(new MyRxJavaErrorHandler()); + RxJavaPlugins.getInstance().registerObservableExecutionHook(new MyRxJavaObservableExecutionHook()); new SleuthRxJavaSchedulersHook(this.tracer, this.traceKeys); - then(SleuthRxJavaPlugins.getInstance().getErrorHandler()).isExactlyInstanceOf(MyRxJavaErrorHandler.class); - then(SleuthRxJavaPlugins.getInstance().getObservableExecutionHook()).isExactlyInstanceOf(MyRxJavaObservableExecutionHook.class); + then(RxJavaPlugins.getInstance().getErrorHandler()).isExactlyInstanceOf(MyRxJavaErrorHandler.class); + then(RxJavaPlugins.getInstance().getObservableExecutionHook()).isExactlyInstanceOf(MyRxJavaObservableExecutionHook.class); } @Test public void should_wrap_delegates_action_in_wrapped_action_when_delegate_is_present_on_schedule() { - SleuthRxJavaPlugins.getInstance().registerSchedulersHook(new MyRxJavaSchedulersHook()); + RxJavaPlugins.getInstance().registerSchedulersHook(new MyRxJavaSchedulersHook()); SleuthRxJavaSchedulersHook schedulersHook = new SleuthRxJavaSchedulersHook( this.tracer, this.traceKeys); Action0 action = schedulersHook.onSchedule(() -> {