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.

(cherry picked from commit 96b0c2f)
  • Loading branch information
gsmet committed Nov 5, 2024
1 parent dc9868b commit f9a46d2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,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 f9a46d2

Please sign in to comment.