Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in QuarkusTestExtension after exception in QuarkusTestResourceLifecycleManager.start() #33371

Closed
famod opened this issue May 15, 2023 · 14 comments · Fixed by #33374
Closed
Labels
area/testing area/user-experience Will make us lose users kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.
Milestone

Comments

@famod
Copy link
Member

famod commented May 15, 2023

Describe the bug

By mistake, I had caused an exception in the start method of my custom MariaDBContainerQuarkusLifecycleManager.

That exception is printed just as expected, but after some skipped QuarkusTests the following exception pops up:

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:901)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:893)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptAfterAllMethod(QuarkusTestExtension.java:887)
        [...]
	Suppressed: org.opentest4j.TestAbortedException: Boot failed
		at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:627)
		at io.quarkus.test.junit.QuarkusTestExtension.interceptBeforeAllMethod(QuarkusTestExtension.java:680)
		at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)

That NPE is a bit misleading and shouldn't be there.

Expected behavior

No NPE

Actual behavior

NPE as described above

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.7.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@famod famod added kind/bug Something isn't working area/testing labels May 15, 2023
@geoand geoand added kind/bug Something isn't working area/user-experience Will make us lose users and removed kind/bug Something isn't working labels May 15, 2023
geoand added a commit to geoand/quarkus that referenced this issue May 15, 2023
geoand added a commit to geoand/quarkus that referenced this issue May 15, 2023
geoand added a commit that referenced this issue May 16, 2023
Present more useful exception when  QuarkusTestResourceLifecycleManager fails
@quarkus-bot quarkus-bot bot added this to the 3.1 - main milestone May 16, 2023
manofthepeace pushed a commit to manofthepeace/quarkus that referenced this issue May 16, 2023
@famod
Copy link
Member Author

famod commented Jun 16, 2023

That NPE still pops up in 3.1.2.Final, reopening...

@famod famod reopened this Jun 16, 2023
@gunnarmorling
Copy link
Contributor

Running into the same issue with 3.2.2.Final.

@geoand
Copy link
Contributor

geoand commented Jul 29, 2023

Same issue? Just throwing an exception in a test resource causes the NPE?

@gunnarmorling
Copy link
Contributor

gunnarmorling commented Jul 29, 2023

Hey @geoand! Wow, what a quick response, on a Saturday nonetheless! So I'm getting the exact same NPE as above, which as I understand is only a follow-up issue to another error. The root cause in my case is this:

[ERROR]   ApplyCommandTest » Runtime java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.BeanArchiveProcessor#build threw an exception: java.lang.IllegalStateException: Failed to index: KafkaConnectResponseExceptionMapper
	at io.quarkus.deployment.index.IndexingUtil.indexClass(IndexingUtil.java:157)
	at io.quarkus.arc.deployment.BeanArchiveProcessor.build(BeanArchiveProcessor.java:94)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:864)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at java.base/java.lang.Thread.run(Thread.java:1623)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.IllegalArgumentException: stream cannot be null
	at org.jboss.jandex.Indexer.indexWithSummary(Indexer.java:2476)
	at io.quarkus.deployment.index.IndexingUtil.indexClass(IndexingUtil.java:152)
	... 10 more

I've seen other reports for that (#14348) and you seemed to have it closed in 2021, but somehow it still seems to be a problem. Intermittently, that is. Here's the commit in kcctl which triggers it in some situations: kcctl/kcctl#358.

@geoand
Copy link
Contributor

geoand commented Jul 29, 2023

Hey @gunnarmorling 👋

Thanks for the additional details.

I'll try again to reproduce this next week.
I think I had tried and failed in the past, but it's definitely worth another shot.

@gunnarmorling
Copy link
Contributor

Yeah, it seems to happen really rarely though. It actually only happened once, since then I couldn't reproduce it. I'll let you know when I run into it again.

@geoand
Copy link
Contributor

geoand commented Jul 29, 2023

👌

@geoand
Copy link
Contributor

geoand commented Jul 31, 2023

I couldn't reproduce this unfortunately...

@gunnarmorling
Copy link
Contributor

Me neither. Some rather rare race condition perhaps?

@geoand
Copy link
Contributor

geoand commented Jul 31, 2023

Very likely... 😭

@famod
Copy link
Member Author

famod commented Aug 8, 2023

I can reproduce it all the time, but there is more to it than running just a single test class.
Instead you seem to need at least one other testclass with a @TestProfile that is running after the initial QuarkusTest that triggered some exception in the manager.
Also, this is how we activate our MariaDB manager per Maven module:

/**
 * {@link QuarkusTestResource QuarkusTestResources} for this module.
 * <p/>
 * This cannot be shared via test-jar because test resources are not picked up from other modules (by design). Subclassing wouldn't work either, see
 * https://github.com/quarkusio/quarkus/issues/10299.
 *
 * @author fmo
 */
@QuarkusTestResource(value = MariaDBContainerQuarkusLifecycleManager.class, parallel = true)
public class ModuleWideQuarkusTestResources {
}

@geoand
Copy link
Contributor

geoand commented Aug 21, 2023

@famod any chance you can attach a small sample that behaves as you mention?

Thanks

@famod
Copy link
Member Author

famod commented Aug 21, 2023

@geoand sure, if the god of time is blessing me 😉

@famod famod added the triage/needs-reproducer We are waiting for a reproducer. label Sep 27, 2023
@geoand
Copy link
Contributor

geoand commented Apr 17, 2024

Let's close this for the time being and we can reopen if more information becomes available

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing area/user-experience Will make us lose users kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants