RemoteReporter implements Reporter { @Override public void close() { try { boolean added = commandQueue .offer(new CloseCommand(), closeEnqueueTimeout, TimeUnit.MILLISECONDS); if (added) { queueProcessorThread.join(10000); } else { log.warn("Unable to cleanly close RemoteReporter, command queue is full - probably the" + " sender is stuck"); } } catch (InterruptedException e) { log.error("Interrupted", e); } finally { try { int n = sender.close(); metrics.reporterSuccess.inc(n); } catch (SenderException e) { metrics.reporterFailure.inc(e.getDroppedSpanCount()); log.error("Remote reporter error", e); } flushTimer.cancel(); } } private  RemoteReporter(Sender sender, int flushInterval, int maxQueueSize, int closeEnqueueTimeout,
      Metrics metrics); @Override void report(JaegerSpan span); @Override void close(); static final int DEFAULT_FLUSH_INTERVAL_MS; static final int DEFAULT_MAX_QUEUE_SIZE; }
@Test public void testCloseLogSenderException() throws SenderException { Appender<ILoggingEvent> mockAppender = mockLogger(e -> { }); final Sender mockedSender = mock(Sender.class); when(mockedSender.close()).thenThrow(SenderException.class); final RemoteReporter testReporter = new RemoteReporter.Builder() .withSender(mockedSender) .build(); testReporter.close(); verify(mockAppender).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() { @Override public boolean matches(ILoggingEvent event) { return event.getFormattedMessage().startsWith("Remote reporter error"); } })); }