code: static Runnable logFailure(final Runnable runnable, Logger logger) {
      return () -> {
        try {
          runnable.run();
        } catch (Throwable t) {
          if (!(t instanceof RejectedExecutionException)) {
            logger.error("An uncaught exception occurred", t);
          }
          throw t;
        }
      };
    }
docs: Returns a wrapped runnable that logs and rethrows uncaught exceptions.