The Artima Developer Community
Sponsored Link




This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.



Posted by Bill Venners on 18 Oct 1998, 9:35 AM

> The only problem that seems to plague the observer idiom in Java is
> the throwing of errors in the listeners. What is your recommendation
> for the cases where the listeners fail to catch errors and it
> ends up blowing up the event generator? Would you typically
> catch and ignore or let the listener blow you up.

This is a good point. I'll have to think about this one, and
would welcome other people's thoughts in the mean time. It
seems to me on first glance that all my fireXXX() method is
supposed to be responsible for is to deliver the event
message to each listener. If a listener has a bug or some
problem which results in an exception, my first inclination
is to catch and ignore the Exception and then continue
passing the event to the other listeners. I wouldn't catch
Errors, but I think I might just be inclined to catch all

The trouble with ignoring an exception is that then when the
fireXXX method is done passing along the message, should it
report back to its caller with some kind of exception? And
what exception?

I think what I lack here is clarity of the fireXXX's contract
and the listener method's contract. I'll think about this
one and post again later.



Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us