GraphiteReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { graphite.close(); } catch (IOException e) { LOGGER.debug("Error disconnecting from Graphite", graphite, e); } } } protected  GraphiteReporter(MetricRegistry registry,
                               GraphiteSender graphite,
                               Clock clock,
                               String prefix,
                               TimeUnit rateUnit,
                               TimeUnit durationUnit,
                               MetricFilter filter,
                               ScheduledExecutorService executor,
                               boolean shutdownExecutorOnStop,
                               Set<MetricAttribute> disabledMetricAttributes); protected  GraphiteReporter(MetricRegistry registry,
                               GraphiteSender graphite,
                               Clock clock,
                               String prefix,
                               TimeUnit rateUnit,
                               TimeUnit durationUnit,
                               MetricFilter filter,
                               ScheduledExecutorService executor,
                               boolean shutdownExecutorOnStop,
                               Set<MetricAttribute> disabledMetricAttributes,
                               boolean addMetricAttributesAsTags); protected  GraphiteReporter(MetricRegistry registry,
                               GraphiteSender graphite,
                               Clock clock,
                               String prefix,
                               TimeUnit rateUnit,
                               TimeUnit durationUnit,
                               MetricFilter filter,
                               ScheduledExecutorService executor,
                               boolean shutdownExecutorOnStop,
                               Set<MetricAttribute> disabledMetricAttributes,
                               boolean addMetricAttributesAsTags,
                               DoubleFunction<String> floatingPointFormatter); static Builder forRegistry(MetricRegistry registry); @Override @SuppressWarnings("rawtypes") void report(SortedMap<String, Gauge> gauges,
                       SortedMap<String, Counter> counters,
                       SortedMap<String, Histogram> histograms,
                       SortedMap<String, Meter> meters,
                       SortedMap<String, Timer> timers); @Override void stop();  }
@Test public void closesConnectionOnReporterStop() throws Exception { reporter.stop(); final InOrder inOrder = inOrder(graphite); inOrder.verify(graphite).connect(); inOrder.verify(graphite).flush(); inOrder.verify(graphite, times(2)).close(); verifyNoMoreInteractions(graphite); }