-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix nullpointer on null code websockets-next #44480
Fix nullpointer on null code websockets-next #44480
Conversation
@@ -239,7 +239,11 @@ public void handle(Void event) { | |||
trafficLogger.connectionClosed(connection); | |||
} | |||
if (closeHandler != null) { | |||
doExecute(connection, new CloseReason(ws.closeStatusCode(), ws.closeReason()), closeHandler); | |||
int code = CloseReason.INTERNAL_SERVER_ERROR.getCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you actually observe a NPE in your app? Because the javadoc WebSocket.closeHandler(Handler<Void>)
is pretty clear that "When the WebSocket received a close frame, the closeStatusCode()
will return the status code and closeReason()
will return the reason."
But maybe I just misundertood.
We could reuse the CloseReason.INTERNAL_SERVER_ERROR
constant, i.e. something like:
CloseReason reason = CloseReason.INTERNAL_SERVER_ERROR;
if (ws.closeStatusCode() != null) {
reason = new CloseReason(ws.closeStatusCode(), ws.closeReason());
}
doExecute(connection, reason, closeHandler);
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you actually observe a NPE in your app? Because the javadoc
WebSocket.closeHandler(Handler<Void>)
is pretty clear that "When the WebSocket received a close frame, thecloseStatusCode()
will return the status code andcloseReason()
will return the reason."
Yes for example closing a websocket server websocat with CTRL+C.
This is also being done in
Line 154 in 5725886
if (code == null) { |
5725886
to
1069847
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Status for workflow
|
Fix nullpointer in ws-next basic connector when the websocket
closeStatusCode
is null.