Class ExceptionLoggingCallable<V>

  • Type Parameters:
    V - the result type of method call.
    All Implemented Interfaces:
    Callable<V>

    public class ExceptionLoggingCallable<V>
    extends Object
    implements Callable<V>
    A callable catching exceptions and virtual machine errors and optionally rethrowing them.
    • Field Detail

      • callable

        protected final Callable<V> callable
        The wrapped callable.
      • rethrow

        protected final boolean rethrow
        Whether to rethrow an occurred exception or virtual machine error.
      • logger

        protected final Logger logger
        The logger with which to log an exception.
    • Constructor Detail

      • ExceptionLoggingCallable

        public ExceptionLoggingCallable​(Callable<V> callable,
                                        boolean rethrow,
                                        Logger logger)
        Wraps the designated callable to catch and log exceptions and virtual machine errors to the designated logger and optionally rethrowing the exception/virtual machine error. In case of a scheduled runnable, rethrowing will stop further executions.
        Parameters:
        callable - The wrapped callable.
        rethrow - Whether to rethrow an occurred exception or virtual machine error.
        logger - The logger with which to log an exception.