lsp4jakarta
lsp4jakarta copied to clipboard
WebSocket: Validate for parameters onMessage message handler
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
- [x] diagnostic
- [ ] quick-fix
- [ ] snippet
- [ ] other, please specify: