Adding InterruptedException to WebSocketObserver methods?

0 views
Skip to first unread message

Ivan

unread,
Oct 19, 2011, 10:34:30 AM10/19/11
to unitt-project
Hi Josh,

How about adding support for thread cancellation mechanism by
extending (or modifying) the present WebSocketObserver interface with
"throws InterruptedException"?

Presently non of the methods in WebSocketObserver declares that an
InterruptedException could be thrown while processing the received
messages. The lack of this declaration obliges the users of
WebSocketObserver to handle such exceptions in the WebSocketObserver's
methods which is most probably not what you want. I could imagine that
on interruption the framework (unitt) tries to close the socket and
perform some quick clean-up before giving up.

Let me know what you think.

Cheers,
Ivan

Josh Morris

unread,
Oct 21, 2011, 11:34:29 AM10/21/11
to unitt-project
I like it. Do you think adding a config option
"closeOnInterruptedExceptions" makes sense?

Josh

Ivan

unread,
Oct 23, 2011, 2:44:42 PM10/23/11
to unitt-project
Hi Josh,

If you see a good use of such an option it might be a good idea.
However, I don't see what else the framework can do besides closing
the socket on an InterruptedException. Unless you have a really good
use case of what you are adding is useful, I would advise to restrain.
Yet again I am not the framework's architect, so it's up to you.

There is one guideline that I use every time I have to add something
(event meta-data) to an API that I am designing. It follows the KISS
(keep-it-short-and-simple) approach: I am very skeptical before
actually adding anything, and only when I have been convinced I add
it. How do I convince myself? Well, I open a discussion ...

I hope that helped.

Cheers,
Ivan

Josh Morris

unread,
Nov 14, 2011, 10:15:21 AM11/14/11
to unitt-project
I will be adding the InterruptedException for a build that I should
have out next week. Things have been crazy at work and I was only just
able to get back into things this weekend.
Reply all
Reply to author
Forward
0 new messages