Skip to content

Commit 5aefcd2

Browse files
committed
Re-enable BlockHound integration tests
Prior to this commit, our BlockHound integration tests were disabled after the migration to a JDK 17 baseline since the build now always runs on JDK 14 or higher. To re-enable the tests we now supply the deprecated -XX:+AllowRedefinitionToAddDeleteMethods command-line argument to the JVM for tests in the Gradle build. Users can also configure this manually within an IDE to run SpringCoreBlockHoundIntegrationTests. If that command-line argument is removed from the JVM at some point in the future, we will need to investigate an alternative solution. See reactor/BlockHound#33 for details.
1 parent f2fe8a8 commit 5aefcd2

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

spring-core/spring-core.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,10 @@ test {
9292
// Make sure the classes dir is used on the test classpath (required by ResourceTests).
9393
// When test fixtures are involved, the JAR is used by default.
9494
classpath = sourceSets.main.output.classesDirs + classpath - files(jar.archiveFile)
95+
96+
// Ensure that BlockHound tests run on JDK 13+. For details, see:
97+
// https://github.com/reactor/BlockHound/issues/33
98+
jvmArgs += [
99+
"-XX:+AllowRedefinitionToAddDeleteMethods"
100+
]
95101
}

spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222

2323
import org.junit.jupiter.api.BeforeAll;
2424
import org.junit.jupiter.api.Test;
25-
import org.junit.jupiter.api.condition.DisabledForJreRange;
2625
import reactor.blockhound.BlockHound;
2726
import reactor.core.scheduler.ReactorBlockHoundIntegration;
2827
import reactor.core.scheduler.Schedulers;
@@ -32,16 +31,23 @@
3231

3332
import static org.assertj.core.api.Assertions.assertThat;
3433
import static org.assertj.core.api.Assertions.assertThatThrownBy;
35-
import static org.junit.jupiter.api.condition.JRE.JAVA_14;
3634

3735
/**
3836
* Tests to verify the spring-core BlockHound integration rules.
3937
*
38+
* <p>NOTE: to run this test class in the IDE, you need to specify the following
39+
* JVM argument. For details, see
40+
* <a href="https://github.com/reactor/BlockHound/issues/33">BlockHound issue 33</a>.
41+
*
42+
* <pre style="code">
43+
* -XX:+AllowRedefinitionToAddDeleteMethods
44+
* </pre>
45+
*
4046
* @author Rossen Stoyanchev
47+
* @author Sam Brannen
4148
* @since 5.2.4
4249
*/
43-
@DisabledForJreRange(min = JAVA_14)
44-
public class SpringCoreBlockHoundIntegrationTests {
50+
class SpringCoreBlockHoundIntegrationTests {
4551

4652

4753
@BeforeAll
@@ -64,7 +70,7 @@ void localVariableTableParameterNameDiscoverer() {
6470
testNonBlockingTask(() -> {
6571
Method setName = TestObject.class.getMethod("setName", String.class);
6672
String[] names = new LocalVariableTableParameterNameDiscoverer().getParameterNames(setName);
67-
assertThat(names).isEqualTo(new String[] {"name"});
73+
assertThat(names).containsExactly("name");
6874
});
6975
}
7076

0 commit comments

Comments
 (0)