Class LoggingUncaughtThreadDeathContextRunnable
- java.lang.Object
-
- org.opendaylight.infrautils.utils.concurrent.LoggingUncaughtThreadDeathContextRunnable
-
- All Implemented Interfaces:
Runnable
public abstract class LoggingUncaughtThreadDeathContextRunnable extends Object implements Runnable
Runnable with finalrun()method that catches any unexpected checked exceptions (RuntimeException&Error) and logs them with some kind of context which allows to better identify the root cause.- Author:
- Michael Vorburger.ch
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLoggingUncaughtThreadDeathContextRunnable(org.slf4j.Logger logger, Supplier<String> debugLogContextSupplier)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidrun()Final run() method; subclasses implementrunWithUncheckedExceptionLogging()instead of this.protected abstract voidrunWithUncheckedExceptionLogging()Run method which you implement instead of the originalrun().static Runnablewrap(Runnable runnable, org.slf4j.Logger logger, Supplier<String> debugLogContextSupplier)Wraps an existing Runnable.
-
-
-
Constructor Detail
-
LoggingUncaughtThreadDeathContextRunnable
protected LoggingUncaughtThreadDeathContextRunnable(org.slf4j.Logger logger, Supplier<String> debugLogContextSupplier)Constructor.- Parameters:
logger- the Logger of the class which created this RunnabledebugLogContextSupplier- supplies useful context included in error log in case of caught checked exception
-
-
Method Detail
-
wrap
public static Runnable wrap(Runnable runnable, org.slf4j.Logger logger, Supplier<String> debugLogContextSupplier)
Wraps an existing Runnable.- Parameters:
logger- the Logger of the class which created this RunnabledebugLogContextSupplier- supplies useful context included in error log in case of caught checked exception
-
run
public final void run()
Final run() method; subclasses implementrunWithUncheckedExceptionLogging()instead of this.
-
runWithUncheckedExceptionLogging
protected abstract void runWithUncheckedExceptionLogging()
Run method which you implement instead of the originalrun().
-
-