Skip to content

Shutdown hook fails with ClassNotFoundException in junit-platform-console-standalone #4469

@singleton11

Description

@singleton11

As it stated in the title, when using junit-platform-console-standalone uses CustomContextClassLoaderExecutor.java which closes classloader after tests are passed, and then JVM terminates which triggers shutdown hook, but classloader already had been closed

For instance, testcontainers installs a shutdown hook.

Console launcher standalone version is 1.11.4, but, I've also built from sources and problem exists

Steps to reproduce

Minimal example, requires org.apache.commons:commons-math3:3.6.1

class MathTest {

    @Test
    void testExample() {
        Runtime.getRuntime()
                .addShutdownHook(new Thread(() -> new BigReal(BigDecimal.ZERO)));
    }
}
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/apache/commons/math3/util/BigReal
        at MathTest.lambda$testExample$0(MathTest.java:11)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.util.BigReal
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
        at java.base/java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:872)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
        ... 2 more

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions