Class ExceptionLoggingRunnable

java.lang.Object
de.aristaflow.adept2.util.threading.ExceptionLoggingRunnable
All Implemented Interfaces:
Runnable

public class ExceptionLoggingRunnable extends Object implements Runnable
A runnable catching runtime exceptions and virtual machine errors and optionally rethrowing them.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Logger
    The logger with which to log an exception.
    protected final boolean
    Whether to rethrow an occurred runtime exception or virtual machine error.
    protected final Runnable
    The wrapped runnable.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExceptionLoggingRunnable(Runnable runnable, boolean rethrow, Logger logger)
    Wraps the designated runnable to catch and log runtime exceptions and virtual machine errors to the designated logger and optionally rethrowing the runtime exception/virtual machine error.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    run()
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • runnable

      protected final Runnable runnable
      The wrapped runnable.
    • rethrow

      protected final boolean rethrow
      Whether to rethrow an occurred runtime exception or virtual machine error. In case of a scheduled runnable, rethrowing will stop further executions.
    • logger

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

    • ExceptionLoggingRunnable

      public ExceptionLoggingRunnable(Runnable runnable, boolean rethrow, Logger logger)
      Wraps the designated runnable to catch and log runtime exceptions and virtual machine errors to the designated logger and optionally rethrowing the runtime exception/virtual machine error. In case of a scheduled runnable, rethrowing will stop further executions.
      Parameters:
      runnable - The wrapped runnable.
      rethrow - Whether to rethrow an occurred runtime exception or virtual machine error.
      logger - The logger with which to log an exception.
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable