From 3fc51f8063ba14bdb0e22c6f87cf71e6b14e0ce3 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 14 Oct 2019 20:08:59 +0100 Subject: [PATCH] Isolate the effects of initializing Reactor's debug agent in the tests --- spring-boot-project/spring-boot/pom.xml | 5 ----- .../reactor/DebugAgentEnvironmentPostProcessor.java | 10 +++++++--- .../DebugAgentEnvironmentPostProcessorTests.java | 2 ++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot/pom.xml b/spring-boot-project/spring-boot/pom.xml index 9ef8c9cc84..cb3d81a582 100644 --- a/spring-boot-project/spring-boot/pom.xml +++ b/spring-boot-project/spring-boot/pom.xml @@ -86,11 +86,6 @@ reactor-netty true - - io.projectreactor - reactor-tools - true - io.netty netty-tcnative-boringssl-static diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessor.java index 4a2c8ba17a..c7daad6af3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessor.java @@ -16,8 +16,6 @@ package org.springframework.boot.reactor; -import reactor.tools.agent.ReactorDebugAgent; - import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.core.Ordered; @@ -46,7 +44,13 @@ public class DebugAgentEnvironmentPostProcessor implements EnvironmentPostProces if (ClassUtils.isPresent(REACTOR_DEBUGAGENT_CLASS, null)) { Boolean agentEnabled = environment.getProperty(DEBUGAGENT_ENABLED_CONFIG_KEY, Boolean.class); if (agentEnabled != Boolean.FALSE) { - ReactorDebugAgent.init(); + try { + Class debugAgent = Class.forName(REACTOR_DEBUGAGENT_CLASS); + debugAgent.getMethod("init").invoke(null); + } + catch (Exception ex) { + throw new RuntimeException("Failed to init Reactor's debug agent"); + } } } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessorTests.java index 626139c2ba..034d7632f1 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/reactor/DebugAgentEnvironmentPostProcessorTests.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import reactor.core.Scannable; import reactor.core.publisher.Flux; +import org.springframework.boot.testsupport.classpath.ClassPathOverrides; import org.springframework.mock.env.MockEnvironment; import static org.assertj.core.api.Assertions.assertThat; @@ -29,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Brian Clozel */ +@ClassPathOverrides("io.projectreactor:reactor-tools:3.3.0.RELEASE") class DebugAgentEnvironmentPostProcessorTests { static {