WebSocket: Validate for parameters onError lifecycle method
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:
Once my PR is reviewed and merged I would be interested in working on this issue.
I would like to work on this while I wait for my PR to be reviewed