Skip to content

Commit

Permalink
Do not throw NPE in AfterAll interceptor if application didn't start
Browse files Browse the repository at this point in the history
This is to solve an issue that we can see from time to time in the CI:

java.lang.NullPointerException: Cannot invoke "io.quarkus.bootstrap.app.RunningQuarkusApplication.getClassLoader()" because "io.quarkus.test.junit.QuarkusTestExtension.runningQuarkusApplication" is null
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:909)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:901)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptAfterAllMethod(QuarkusTestExtension.java:895)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1116)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	Suppressed: org.opentest4j.TestAbortedException: Boot failed

For instance here:
#43448 (comment)
in the io.quarkus.it.mongodb.BookResourceTest failure.
  • Loading branch information
gsmet committed Oct 29, 2024
1 parent 123ea8e commit 96b0c2f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ public void interceptAfterEachMethod(Invocation<Void> invocation, ReflectiveInvo
@Override
public void interceptAfterAllMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
if (runningQuarkusApplication == null || isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
invocation.proceed();
return;
}
Expand Down

0 comments on commit 96b0c2f

Please sign in to comment.