Can't use lambda expression for MessageHandler
Neither of the following two lambda expression work, when registering a PongMessage handler.
session.addMessageHandler((MessageHandler.Whole<PongMessage>) message -> {
});
session.addMessageHandler(PongMessage.class, message -> {
});
The reason is, that the internal method static Class<?> getHandlerType(MessageHandler handler) returns Object instead of PongMessage for the type.
The workaround for this issue is to not using lambdas, but implement the interface on a class and use that:
class PongHandler implements MessageHandler.Whole<PongMessage>
I've just come across this one. It looks to be caused by the type erasure of the lambda expression as TyrusSession#notifyPongHandler is trying to infer the type rather than getting it explicitly from the MessageHandlerManager#registeredHandlers. As PongMessage can only use MessageHandler.Whole types, I think this can be replace with getMessageHandler(Class). I'll submit a patch when I get a few minutes.