Hello all,

While porting the proton-c reactor to Java, I've found a few error paths that I 
wasn't sure how best to handle.

I have some ideas (see below), but if this stuff is already written down 
somewhere - feel free to suitably admonish me (and then point me towards it...)

1) When an error occurs while the reactor is servicing a connection: the 
connection is closed with a transport error.  This is already implemented by 
various functions in reactor/connection.c (e.g. pni_handle_bound, to pick one 
at random), so I expect Java following suit shouldn't be too contentious.

2) When an error occurs while the reactor is accepting a connection: a 
PN_SELECTABLE_ERROR event is delivered to the acceptor's collector.  This might 
necessitate a new pn_acceptor_attachments function to associate a handler with 
an acceptor (casting to selectable strikes me as something that might break in 
the future...).  Aside: should it be possible to associate a pn_error (Java 
Throwable?) with an event, so that it is possible to report the underlying 
cause for a PN_SELECTABLE_ERROR?

3) In the Java reactor it is possible for an unchecked (derived from 
RuntimeException) exception to be thrown from a handler.  Delivering a 
PN_SELECTABLE_ERROR to the selectable seems like the wrong thing to do (because 
the handler that threw the exception might not be associated with a selectable, 
or the exception could be thrown while handling PN_SELECTABLE_ERROR).  Logging 
the exception then swallowing it seems likely to result in situations where the 
reactor appears to have hung.  So the best I've come up with is that the Java 
equivalent of pn_reactor_process throws an exception - but then I'm not clear 
what state the reactor should be left in?  Permanently failing, by throwing a 
"ReactorBorked" exception from any future pn_reactor_process invocation?  Also, 
if this happens should the reactor be responsible for reclaiming the resources 
used by its children (e.g. closing their sockets)?

Thanks,
- Adrian

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Reply via email to