@Test public void context_close_stopsNotifier() { notifier.onApplicationEvent(mock(ApplicationReadyEvent.class)); context.close(); Assertions.assertThat(notifier.running).isFalse(); }
@Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } @Autowired  Notifier(NotifierConfig notifierConfig, ObjectMapper objectMapper, RestTemplate restTemplate); }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } @Autowired  Notifier(NotifierConfig notifierConfig, ObjectMapper objectMapper, RestTemplate restTemplate); @PreDestroy void stopLooperThread(); @Override void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent); }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } @Autowired  Notifier(NotifierConfig notifierConfig, ObjectMapper objectMapper, RestTemplate restTemplate); @PreDestroy void stopLooperThread(); @Override void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent);  }