private Runnable getScheduleableAction(String actionName, Runnable runnable) {
    return () -> {
      try {
        if (!isShuttingDown) {
          runnable.run();
          /*
           * Expects all run() implementations <b>not to swallow the interrupts.</b>
           * This thread is interrupted from an external source(mostly executor service) to die.
           */
          if (Thread.currentThread().isInterrupted()) {
            LOG.warn("Action: {} is interrupted.", actionName);
            doCleanUpOnTaskException(new InterruptedException());
          } else {
            LOG.info("Action: {} completed successfully.", actionName);
          }
        }
      } catch (Throwable throwable) {
        LOG.error("Execution of action: {} failed.", actionName, throwable);
        doCleanUpOnTaskException(throwable);
      }
    };
  }
Decorate the executable action with exception handlers to facilitate cleanup on failures.

@param actionName the name of the scheduleable action.
@param runnable the action to execute.
@return the executable action decorated with exception handlers.
samza-core/src/main/java/org/apache/samza/zk/ScheduleAfterDebounceTime.java