Class CleanupCallable<V>

java.lang.Object
de.aristaflow.adept2.util.threading.CleanupCallable<V>
Type Parameters:
V - the result type of method call.
All Implemented Interfaces:
Callable<V>

public class CleanupCallable<V> extends Object implements Callable<V>
A cleanup callable executes a callable and afterwards a special cleanup consuming runnable finally after the first callable. Problems occurring in the cleanup will be logged to the designated logger. This way exceptions from the first callable will not be swallowed.
  • Field Details

    • callable

      protected final Callable<V> callable
      The callable executed normally.
    • cleanup

      protected final ConsumingRunnable<V,Throwable> cleanup
      The cleanup runnable executed after the normal execution has terminated.
    • logger

      protected final Logger logger
      The logger for logging exceptions from the cleanup runnable.
  • Constructor Details

    • CleanupCallable

      public CleanupCallable(Callable<V> callable, ConsumingRunnable<V,Throwable> cleanup, Logger logger)
      Creates a new cleanup runnable executing the callable and the cleanup runnable finally after the callable. Problems occurring in the cleanup will be logged to the designated logger.
      Parameters:
      callable - The callable executed normally.
      cleanup - The cleanup runnable executed after the normal execution has terminated.
      logger - The logger for logging exceptions from the cleanup.
  • Method Details