Skip to content

Commit 1a0e008

Browse files
committed
Prevent Netty tcNative from loading classes with wrong class loader
In our tests, the JNI code in Netty tcNative can cause some of its classes to be loaded using a ModifiedClassPathClassLoader. When the wrong class loader is used, SSL-related tests fail, for example due to the same Netty tcNative classes being loaded by two different ClassLoders and no longer being the same. This appears to be dependent upon the order in which tests are executed and results in intermittent test failures. It looks like this should be addressed in Netty tcNative 2.0.40 which preloads all of its classes. In the meantime, this commit updates ModifiedClassPathClassLodaer to ignore Netty tcNative classes so that they're only ever loaded by the system class loader. Closes gh-26749
1 parent faeda6f commit 1a0e008

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
7777

7878
@Override
7979
public Class<?> loadClass(String name) throws ClassNotFoundException {
80-
if (name.startsWith("org.junit") || name.startsWith("org.hamcrest")) {
80+
if (name.startsWith("org.junit") || name.startsWith("org.hamcrest")
81+
|| name.startsWith("io.netty.internal.tcnative")) {
8182
return Class.forName(name, false, this.junitLoader);
8283
}
8384
return super.loadClass(name);

0 commit comments

Comments
 (0)