elharo commented on PR #1156: URL: https://github.com/apache/commons-lang/pull/1156#issuecomment-1902632362
Do we have any estimate of how much this class is used? If there are a lot fo projects that depend on it, that would prove me wrong about its utility. Though given your description and thinking about exceptions in particular, I'm more worried than ever about this class. The typical event listener/Observer pattern is to handle events as they occur, one at a time. At least that's the abstraction that's surfaced through the API. Each exception will be handled before the next event is processed, or it will shut down the thread if it isn't handled. The pattern is not batch up a bunch of tasks, handle them all, and then deal with errors. In synchronous event listeners, error handling or process termination as a result of one event happens *before* the next event is handled. Of course an event can spawn a thread or an asynchronous task, but that is not what EventListenerSupport is doing. EventListenerSupport is synchronous. Events are handled in order. A failure to handle one event can have implications for how or whether to handle the next event. Conceptually there are two cases here: 1. An expected, possible exception, usually checked 2. An unexpected exception, usually unchecked. In the second case, the event listener absolutely should shut down, as should everything else. In the first case the exception needs to be handled. It's just a question of where and when. What an error listener might do is give devs the option to defer or relocate the normal error handling. It should also give devs the option to continue processing the other events if they're independent, or to abort processing if they're not. OTOH suppose the events are very dependent — e.g. every event writes a record in a database and the credentials are wrong. I might want one try-catch to wrap and handle SQL exceptions from all invocations. In that case, maybe just don't install an error handler? That is, error handlers are for cases where events are independent, and normal processing for cases where they are dependent. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
