Hi all,
as you might have noticed, I filed blocker bug against WEBSOCKET_SPEC
project - [1].
The main issue is that current Session.addMessageHandler method cannot
handle message handlers in form of lambda expressions, because there is
no information about its generic type parameter available. We discussed
this issue with Brian Goetz and he pointed out that current API is wrong
not only for this case, but also for more complicated generics usages
and is reliable only for anonymous classes created directly from
MessageHandler.Whole and MessageHandler.Partial (type information is in
the generated class file), so the issue itself is not limited only to
Java SE 8.
We think that this issue is important enough to fix it in a Maintenance
Release as soon as possible, not tied to Java EE 8 planning or anything
else.
Proposed solution is to add two additional Session.addMessageHandler
methods with explicit type information, please see [2] for more complete
description. I also attached updated version of the specification
document. There is only one addition - last paragraph in chapter 2.1.3
"Receiving Messages" and the sample code in chapter 2.1.4 "Sending
Messages" was modified to use the newly introduced addMessageHandler
method with explicit type.
Complete change diff can be seen here [3] (but it contains lots of noise
- spec licence etc; changes.txt should be good enough for evaluation).
Any feedback would be greatly appreciated!
Thanks and regards,
Pavel
[1]:
https://java.net/jira/browse/WEBSOCKET_SPEC-226
[2]:
https://github.com/pavelbucek/websocket-spec/blob/WEBSOCKET_SPEC-226/websocket-1.1-changes.txt
[3]:
https://github.com/pavelbucek/websocket-spec/pull/1/files