mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Karasulu" <akaras...@apache.org>
Subject Re: Is the ExceptionMonitor usefull ?
Date Sat, 05 Jul 2008 13:27:49 GMT
I think this was something Trustin and I talked about while experimenting
with Monitors verses logging.  This was from some concepts that Paul Hammant
was expounding via Pico Container.  It was a bad idea then and I think it is
a bad idea now.  Not bad rather but just worthless Thoughtworks
masterbation.

Alex

On Thu, Jul 3, 2008 at 12:46 PM, Emmanuel Lecharny <elecharny@apache.org>
wrote:

> Hi guys,
>
> I'm currently spending some time documenting the AbstractIoService class,
> where the ExceptionMonitor instance is created. This class is just used to
> handle exception when they are uncaught :
>
> /**
> * Monitors uncaught exceptions.  {@link #exceptionCaught(Throwable)} is
> * invoked when there are any uncaught exceptions.
> */
> public abstract class ExceptionMonitor {
> ...
>
>
> At least, this is what the Javadoc says ... But in fact, 'uncaught
> exception' does not make a lot of sense. Either we catch an exception, or
> not. If we don't catch it, there is no way to deal with it as an uncaught
> exception, because otherwise, it means it has been caught, and is not
> anymore uncaught ... :/
>
> There is soemthing wrong in this logic. All over the code, we see things
> like :
>
> try {
> ...
> } catch (Throwable t) {
>   ExceptionMonitor.getInstance().exceptionCaught(t);
> }
>
> Assuming that we are using the DefaultExceptionMonitor, this will simply
> log a warning in some log :
>
> public class DefaultExceptionMonitor extends ExceptionMonitor {
>   private final Logger log =
> LoggerFactory.getLogger(DefaultExceptionMonitor.class);
>
>   public void exceptionCaught(Throwable cause) {
>       if (log.isWarnEnabled()) {
>           log.warn("Unexpected exception.", cause);
>       }
>   }
>
> Why don't we simply write :
> try {
>   ...
> } catch (Throwable t) {
>   log.warn("Unexpected exception.", t);
> }
>
> ?
>
> Now, the question is why do we allow a user to define it's own
> ExceptionMonitor to handle unhandled exceptions. As we are defining a
> framework, it does not make a lot of sense to disregard an exception and let
> the user define what to do with it, as the user will have _no clue_ about
> where those kind of exception might be produced (our users are not all
> supposed to go through MINA code).
>
> So do we really need this class ? IMHO, this is a bad idea which has not
> been removed from the very first version (it comes far away : the class has
> been injected back in 2005, and was never derived since, if we except the
> default implementation.
>
> wdyt ?
>
> --
> --
> cordialement, regards,
> Emmanuel L├ęcharny
> www.iktek.com
> directory.apache.org
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message