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

WebSocket: Validate for parameters onMessage message handler #244

Open
1 of 4 tasks
Tracked by #16
dalidia opened this issue Feb 10, 2022 · 0 comments · May be fixed by #277
Open
1 of 4 tasks
Tracked by #16

WebSocket: Validate for parameters onMessage message handler #244

dalidia opened this issue Feb 10, 2022 · 0 comments · May be fixed by #277
Assignees
Labels
diagnostic Diagnostic item

Comments

@dalidia
Copy link
Contributor

dalidia commented Feb 10, 2022

Description:

Currently, if a user adds a non-valid parameter to methods annotated with @onMessage to classes annotated with @ServerEndpoint or @ClientEndpoint, it will create a server error, leaving the server unresponsive. However, the user is not notified of this in the IDE. Only a small error shows up in the terminal.

For this reason, we need to apply a validation of parameters for the onMessage lifecycle method.

Specification:

Each OnMessage method handles: text, binary and pong, per JakartaEE specs found here

Acceptable
@OnMessage
public void validMessage(String message, Session session) {
    System.out.println("Program requested " + message + " using " + session.getId());
    session.getAsyncRemote().sendText("Lucky says hi");
}
Error
@OnMessage
public void notValidMessage(Object invalidMessage, Session session) {
   System.out.println("Method has invalid parameter java.lang.Class. " + invalidParameter + " using " + session.getId());
   session.getAsyncRemote().sendText("I am pong");
}

Type of language feature proposed:

Select all that apply

  • diagnostic
  • quick-fix
  • snippet
  • other, please specify:
@kathrynkodama kathrynkodama added the diagnostic Diagnostic item label Feb 10, 2022
@dalidia dalidia changed the title WebSocket: Validate for parameters OnMessage lifecycle method WebSocket: Validate for parameters onMessage lifecycle method Feb 11, 2022
@dalidia dalidia changed the title WebSocket: Validate for parameters onMessage lifecycle method WebSocket: Validate for parameters onMessage message handler Feb 11, 2022
@TheAvi123 TheAvi123 self-assigned this Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic Diagnostic item
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants