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

NullPointerException in MultiConcatMapOp #1498

Closed
markusdlugi opened this issue Jan 26, 2024 · 4 comments · Fixed by #1499
Closed

NullPointerException in MultiConcatMapOp #1498

markusdlugi opened this issue Jan 26, 2024 · 4 comments · Fixed by #1499
Assignees
Labels
bug Something isn't working
Milestone

Comments

@markusdlugi
Copy link
Contributor

Context

We tried to update our application to Quarkus 3.7.0 which is shipping the latest Mutiny version 2.5.5, but one of our unit tests is failing due to a NPE in Mutiny.

Description

The exception stack trace:

java.lang.NullPointerException: Cannot invoke "java.util.concurrent.Flow$Subscription.request(long)" because "this.innerUpstream" is null

	at io.smallrye.mutiny.operators.multi.MultiConcatMapOp$MainSubscriber.request(MultiConcatMapOp.java:250)
	at io.smallrye.mutiny.helpers.test.AssertSubscriber.request(AssertSubscriber.java:711)
	at io.smallrye.mutiny.helpers.test.AssertSubscriber.awaitNextItemEvents(AssertSubscriber.java:614)
	at io.smallrye.mutiny.helpers.test.AssertSubscriber.awaitNextItems(AssertSubscriber.java:395)
	at io.smallrye.mutiny.helpers.test.AssertSubscriber.awaitNextItems(AssertSubscriber.java:373)
	at com.acme.ReproducerQuarkusTest.testNullPointerException(ReproducerQuarkusTest.java:41)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:1013)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:827)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Additional details

I was able to create a minimal reproducer:

@Inject
Vertx vertx;

public Multi<Long> nullPointerException() {
	return Multi.createFrom().ticks().every(Duration.ofSeconds(30))
			.onItem().call(i -> vertx.executeBlocking(() -> null));
}

Tested in a @QuarkusTest using:

@Test
void testNullPointerException() {
	testee.nullPointerException().subscribe().withSubscriber(AssertSubscriber.create(1))
			.awaitNextItems(1, Duration.ofSeconds(3));
}

The test passes sometimes, but sometimes it doesn't, so maybe some kind of race condition?

@jponge
Copy link
Member

jponge commented Jan 26, 2024

Thanks, we'll have a look in the coming days

@jponge
Copy link
Member

jponge commented Jan 26, 2024

There's indeed a very narrow chance the first inner upstream hasn't arrived yet.

The fix will be a simple null check. I'm trying to reproduce this in pure Mutiny (no Quarkus, no Vert.x, but this isn't easy 🤣)

@jponge jponge added the bug Something isn't working label Jan 26, 2024
@jponge jponge added this to the 2.5.6 milestone Jan 26, 2024
@jponge jponge self-assigned this Jan 26, 2024
@jponge jponge linked a pull request Jan 26, 2024 that will close this issue
@jponge
Copy link
Member

jponge commented Jan 26, 2024

I even found a deadlock, thanks @markusdlugi

@markusdlugi
Copy link
Contributor Author

Perfect, thanks a lot for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants