Summary: | NPE when using a lambda in Session.addMessageHandler | ||
---|---|---|---|
Product: | Tomcat 8 | Reporter: | Emmanuel L <elecharny> |
Component: | WebSocket | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | critical | ||
Priority: | P2 | ||
Version: | 8.5.50 | ||
Target Milestone: | ---- | ||
Hardware: | PC | ||
OS: | Mac OS X 10.1 |
Description
Emmanuel L
2021-07-20 15:38:50 UTC
This is why the method: public <T> void addMessageHandler(Class<T> clazz, Whole<T> handler) was added to WsSession. There are some instances, and this is one, where the generic type isn't available at run time. We could catch the NPE and have Util.getGenericType() return null but that will just move the NPE one step up the call stack. There doesn't seem much point in adding the code to do that. Makes sense, and agreed that there is no need to catch the NPE here. It's a bit sad that the way Java generates the Lambda code results in a none typed handler. Thanks for the pointer to the other method, will try that. |