StatisticsReporterSchedulerComponentImpl implements StatisticsReporterSchedulerComponent { void guardedCall(Runnable r) { if (outstanding.compareAndSet(false,true)) { try { r.run(); } finally { outstanding.set(false); } } } StatisticsReporterSchedulerComponentImpl(@Config(name = "statistics.scheduler.enabled", value = "true") final boolean enabled); @ExecuteBefore(State.STARTED) void start(StatisticsReporterComponent src); @ExecuteBefore(State.STOPPED) void stop(StatisticsReporterComponent src);  }
@Test void guardedCallClean() { final AtomicBoolean called = new AtomicBoolean(); final StatisticsReporterSchedulerComponentImpl instance = new StatisticsReporterSchedulerComponentImpl(true); instance.guardedCall(() -> {}); instance.guardedCall(() -> called.set(true)); assertTrue(called.get()); }