users@websocket-spec.java.net

[jsr356-users] History of Future<SendResult> and SendHandler decisions?

From: Joakim Erdfelt <joakim_at_intalio.com>
Date: Fri, 14 Dec 2012 09:59:56 -0700

(Note: I suspect there's a reason for this, as I see statements around
making decisions for future proofing and new Java 8 semantics)

The SendResult object seems to overlap with the role of Future itself.

If I do ...

Future<SendResult> fut = session.getRemote().sendBytesByFuture(buf);
SendResult res = fut.get();

I would expect the future to return on success, and throw an exception on
failure.
Why would I want to query the SendResult.isOK() ever?

Barring any sort of identification being returned, the method signature
could be ...

Future<Void> RemoteEndpoint.sendBytesByFuture(buf);

... is just as valid.

Also, why is SendHandler the way it is?
I would expect it to be something like this ...

public interface SendHandler {
   void onResultSuccess();
   void onResultFailure(Throwable t);
}

Is the one method approach found in the 008 spec document something to do
with the Java 8 lambda friendly decision making?

--
Joakim Erdfelt <joakim_at_intalio.com>
webtide.com <http://www.webtide.com/>
Developer advice, services and support
from the Jetty & CometD experts
eclipse.org/jetty - cometd.org