lsp4jakarta icon indicating copy to clipboard operation
lsp4jakarta copied to clipboard

WebSocket: Validate for parameters onError lifecycle method

Open dalidia opened this issue 3 years ago • 2 comments

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

  • [x] diagnostic
  • [ ] quick-fix
  • [ ] snippet
  • [ ] other, please specify:

dalidia avatar Feb 11 '22 07:02 dalidia

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

giancarlopernudisegura avatar Mar 17 '22 23:03 giancarlopernudisegura

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

dalidia avatar Apr 06 '22 18:04 dalidia