Skip to content

Commit

Permalink
Prevent Netty tcNative from loading classes with wrong class loader
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wilkinsona committed Jun 8, 2021
1 parent faeda6f commit 1a0e008
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {

@Override
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 super.loadClass(name);
Expand Down

0 comments on commit 1a0e008

Please sign in to comment.