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 onError lifecycle method #249

Open
1 of 4 tasks
Tracked by #16
dalidia opened this issue Feb 11, 2022 · 2 comments · May be fixed by #289
Open
1 of 4 tasks
Tracked by #16

WebSocket: Validate for parameters onError lifecycle method #249

dalidia opened this issue Feb 11, 2022 · 2 comments · May be fixed by #289
Assignees
Labels
diagnostic Diagnostic item

Comments

@dalidia
Copy link
Contributor

dalidia commented Feb 11, 2022

Description:

Currently, if a user adds a non-valid parameter to methods annotated with @onError 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 onError lifecycle method.

Specification:

Valid parameters are defined as "an optional Session parameter, a mandatory Throwable parameter, and zero to n parameters (of type String, any Java primitive type or boxed version thereof) annotated with a @PathParam annotation as parameters" per JakartaEE specs found here

Acceptable
@onError
public void validError(Throwable error, Session session) {
    System.out.println("Program requested " + message + " using " + session.getId());
    session.getAsyncRemote().sendText("Lucky says hi");
}
Error
@onError
public void notValidError(Session session) {
   System.out.println("Program requested " + invalidParameter + " using " + session.getId());
   session.getAsyncRemote().sendText("I am invalid. I am missing a mandatory Throwable parameter");
}

Type of language feature proposed:

Select all that apply

  • diagnostic
  • quick-fix
  • snippet
  • other, please specify:
@dalidia dalidia added the diagnostic Diagnostic item label Feb 11, 2022
@giancarlopernudisegura
Copy link
Contributor

Once my PR is reviewed and merged I would be interested in working on this issue.

@dalidia
Copy link
Contributor Author

dalidia commented Apr 6, 2022

I would like to work on this while I wait for my PR to be reviewed

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.

2 participants