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 websockets-next #42271

Closed
RobertoUa opened this issue Aug 1, 2024 · 4 comments · Fixed by #42282
Closed

NPE in websockets-next #42271

RobertoUa opened this issue Aug 1, 2024 · 4 comments · Fixed by #42282
Labels
area/websockets kind/bug Something isn't working
Milestone

Comments

@RobertoUa
Copy link

Describe the bug

Getting NPE

java.lang.NullPointerException: Cannot invoke "java.lang.Short.shortValue()" because the return value of "io.vertx.core.http.WebSocketBase.closeStatusCode()" is null
	at io.quarkus.websockets.next.runtime.WebSocketConnectionBase.closeReason(WebSocketConnectionBase.java:134)
	at myapp.core.stream.Streaming_WebSocketServerEndpoint.doOnClose(Unknown Source)
	at io.quarkus.websockets.next.runtime.WebSocketEndpointBase$4.call(WebSocketEndpointBase.java:158)
	at io.quarkus.websockets.next.runtime.WebSocketEndpointBase$4.call(WebSocketEndpointBase.java:152)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$0(ContextImpl.java:178)
	at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279)
	at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:210)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)

It seems like error is happening here

closeStatusCode is Short and it's null. It throws when it tries to unbox (Short -> short)

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

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

No response

Additional information

No response

@RobertoUa RobertoUa added the kind/bug Something isn't working label Aug 1, 2024
@geoand
Copy link
Contributor

geoand commented Aug 1, 2024

cc @mkouba

@mkouba
Copy link
Contributor

mkouba commented Aug 2, 2024

Hm, this could only happen if an @OnClose callback accepts a CloseReason param but when it's called the underlying WebSocket is not closed yet. And that should not normally happen.

@RobertoUa Could you tell me a little bit more about your application/use case?

@RobertoUa
Copy link
Author

it happens every time the connection is terminated abruptly. Reproduces every time when I connect with websocat and then kill -9 it.
But sometimes it happens with a regular browser, I couldn't figure out how and when it happens.

I also don't think it's a timeout from reverse proxy/load balancer, I do pings and connections could stay alive for hours.

mkouba added a commit to mkouba/quarkus that referenced this issue Aug 2, 2024
- fix invocation of OnClose callback with a CloseReason param
- resolves quarkusio#42271
@mkouba
Copy link
Contributor

mkouba commented Aug 2, 2024

Reproduces every time when I connect with websocat and then kill -9 it.

Yes, I was able to reproduce the problem locally. There's not much we can do about it though. I've modified the code to use CloseReason.INTERNAL_SERVER_ERROR instead.

@quarkus-bot quarkus-bot bot added this to the 3.14 - main milestone Aug 2, 2024
@gsmet gsmet modified the milestones: 3.14 - main, 3.13.1 Aug 6, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 6, 2024
- fix invocation of OnClose callback with a CloseReason param
- resolves quarkusio#42271

(cherry picked from commit 983b8bf)
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
- fix invocation of OnClose callback with a CloseReason param
- resolves quarkusio#42271
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/websockets kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants