I'm attempting to use the library for a project at my job, and I'm running into a problem because the BinaryLogClient will continue dispatching events to every EventListener, even if one (or all) of the listeners throws an exception on a previous event.
I have a proposed refactoring in order to make failure handling more flexible. The core ideas (ignoring backward compatibility for a moment, and imagining an ideal world) are:
BinaryLogClient should only have one EventListener and one LifecycleListener.
- When the one
EventListener throws an exception, the BinaryLogClient should abort and disconnect immediately.
- The multiple listener behavior in the current library should be factored out into a
BroadcastEventListener (and a BroadcastLifecycleListener) that handles the registration/unregistration logic, dispatches to the registered listeners, and "swallows" the child listeners' exceptions if desired (the same behavior as the current code).
I have started a fork exploring these ideas (sacundim@8edbda1). In order not to break existing code that uses the library, I've modified the ideas described above in this way:
BinaryLogClient should continue to behave exactly the same way as it does now.
- I've added a class
AbstractBinaryLogClient and moved most of the original logic there.
I still have three issues I'd like to work through, though:
- My changes so far still break compatibility with existing code, because
BinaryLogClient.LifecycleListener has methods that take a BinaryLogClient argument. In my modified code as of now, this needs to be changed to AbstractBinaryLogClient, which means that existing LifecycleListener implementations will no longer compile.
- I'm still generally just not certain that I have the best factoring.
- I haven't run any tests yet.
I'd appreciate to have your input into this matter.
I'm attempting to use the library for a project at my job, and I'm running into a problem because the
BinaryLogClientwill continue dispatching events to everyEventListener, even if one (or all) of the listeners throws an exception on a previous event.I have a proposed refactoring in order to make failure handling more flexible. The core ideas (ignoring backward compatibility for a moment, and imagining an ideal world) are:
BinaryLogClientshould only have oneEventListenerand oneLifecycleListener.EventListenerthrows an exception, theBinaryLogClientshould abort and disconnect immediately.BroadcastEventListener(and aBroadcastLifecycleListener) that handles the registration/unregistration logic, dispatches to the registered listeners, and "swallows" the child listeners' exceptions if desired (the same behavior as the current code).I have started a fork exploring these ideas (sacundim@8edbda1). In order not to break existing code that uses the library, I've modified the ideas described above in this way:
BinaryLogClientshould continue to behave exactly the same way as it does now.AbstractBinaryLogClientand moved most of the original logic there.I still have three issues I'd like to work through, though:
BinaryLogClient.LifecycleListenerhas methods that take aBinaryLogClientargument. In my modified code as of now, this needs to be changed toAbstractBinaryLogClient, which means that existingLifecycleListenerimplementations will no longer compile.I'd appreciate to have your input into this matter.