ChainedListener implements InstrumentedContext.Listener { @Override public void task(Task<?> task) { guardedCall(() -> first.task(task)); guardedCall(() -> second.task(task)); } ChainedListener(InstrumentedContext.Listener first,
                  InstrumentedContext.Listener second,
                  Logger logger); @Override void task(Task<?> task); @Override void status(TaskId taskId, Phase phase); @Override void meta(TaskId taskId, Map<String, String> data); @Override void close();  }
@Test public void testTask() throws Exception { sut.task(task); verify(first).task(task); verify(second).task(task); }
@Test public void testHandlesExceptionOnTask() throws Exception { RuntimeException exception = new RuntimeException(); doThrow(exception).when(first).task(any()); sut.task(task); verify(logger).warn("Exception", exception); verify(second).task(task); }