Commit 1a0e008a authored by Andy Wilkinson's avatar Andy Wilkinson

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
parent faeda6f9
...@@ -77,7 +77,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader { ...@@ -77,7 +77,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
@Override @Override
public Class<?> loadClass(String name) throws ClassNotFoundException { public Class<?> loadClass(String name) throws ClassNotFoundException {
if (name.startsWith("org.junit") || name.startsWith("org.hamcrest")) { if (name.startsWith("org.junit") || name.startsWith("org.hamcrest")
|| name.startsWith("io.netty.internal.tcnative")) {
return Class.forName(name, false, this.junitLoader); return Class.forName(name, false, this.junitLoader);
} }
return super.loadClass(name); return super.loadClass(name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment