@Test public void executionThrowsError() throws InterruptedException { final CountDownLatch cdl = new CountDownLatch(1); final Runnable runnable = new Runnable() { private boolean hasRun = false; @Override public void run() { if (hasRun) { cdl.countDown(); } else { hasRun = true; throw new RuntimeException(); } } }; final TesseraScheduledExecutor executor = new TesseraScheduledExecutor(Executors.newSingleThreadScheduledExecutor(), runnable, 2,2); executor.start(); final boolean await = cdl.await(5, TimeUnit.SECONDS); assertThat(await).isTrue(); }
@PostConstruct public void start() { LOGGER.info("Starting {}", this.action.getClass().getSimpleName()); final Runnable exceptionSafeRunnable = () -> { try { LOGGER.debug("{} has started running", action.getClass().getSimpleName()); this.action.run(); } catch (final Throwable ex) { LOGGER.error( "Error when executing action {}, exception details:", action.getClass().getSimpleName(), ex); } finally { LOGGER.debug("{} has finished running", action.getClass().getSimpleName()); } }; this.executor.scheduleWithFixedDelay(exceptionSafeRunnable, initialDelay, rate, TimeUnit.MILLISECONDS); LOGGER.info("Started {}", this.action.getClass().getSimpleName()); }
TesseraScheduledExecutor { @PostConstruct public void start() { LOGGER.info("Starting {}", this.action.getClass().getSimpleName()); final Runnable exceptionSafeRunnable = () -> { try { LOGGER.debug("{} has started running", action.getClass().getSimpleName()); this.action.run(); } catch (final Throwable ex) { LOGGER.error( "Error when executing action {}, exception details:", action.getClass().getSimpleName(), ex); } finally { LOGGER.debug("{} has finished running", action.getClass().getSimpleName()); } }; this.executor.scheduleWithFixedDelay(exceptionSafeRunnable, initialDelay, rate, TimeUnit.MILLISECONDS); LOGGER.info("Started {}", this.action.getClass().getSimpleName()); } }
TesseraScheduledExecutor { @PostConstruct public void start() { LOGGER.info("Starting {}", this.action.getClass().getSimpleName()); final Runnable exceptionSafeRunnable = () -> { try { LOGGER.debug("{} has started running", action.getClass().getSimpleName()); this.action.run(); } catch (final Throwable ex) { LOGGER.error( "Error when executing action {}, exception details:", action.getClass().getSimpleName(), ex); } finally { LOGGER.debug("{} has finished running", action.getClass().getSimpleName()); } }; this.executor.scheduleWithFixedDelay(exceptionSafeRunnable, initialDelay, rate, TimeUnit.MILLISECONDS); LOGGER.info("Started {}", this.action.getClass().getSimpleName()); } TesseraScheduledExecutor(
            final ScheduledExecutorService executor, final Runnable action, final long rate, final long delay); }
TesseraScheduledExecutor { @PostConstruct public void start() { LOGGER.info("Starting {}", this.action.getClass().getSimpleName()); final Runnable exceptionSafeRunnable = () -> { try { LOGGER.debug("{} has started running", action.getClass().getSimpleName()); this.action.run(); } catch (final Throwable ex) { LOGGER.error( "Error when executing action {}, exception details:", action.getClass().getSimpleName(), ex); } finally { LOGGER.debug("{} has finished running", action.getClass().getSimpleName()); } }; this.executor.scheduleWithFixedDelay(exceptionSafeRunnable, initialDelay, rate, TimeUnit.MILLISECONDS); LOGGER.info("Started {}", this.action.getClass().getSimpleName()); } TesseraScheduledExecutor(
            final ScheduledExecutorService executor, final Runnable action, final long rate, final long delay); @PostConstruct void start(); @PreDestroy void stop(); }
TesseraScheduledExecutor { @PostConstruct public void start() { LOGGER.info("Starting {}", this.action.getClass().getSimpleName()); final Runnable exceptionSafeRunnable = () -> { try { LOGGER.debug("{} has started running", action.getClass().getSimpleName()); this.action.run(); } catch (final Throwable ex) { LOGGER.error( "Error when executing action {}, exception details:", action.getClass().getSimpleName(), ex); } finally { LOGGER.debug("{} has finished running", action.getClass().getSimpleName()); } }; this.executor.scheduleWithFixedDelay(exceptionSafeRunnable, initialDelay, rate, TimeUnit.MILLISECONDS); LOGGER.info("Started {}", this.action.getClass().getSimpleName()); } TesseraScheduledExecutor(
            final ScheduledExecutorService executor, final Runnable action, final long rate, final long delay); @PostConstruct void start(); @PreDestroy void stop();  }