Collector { public void stop() { try { try { for (final Counter counter : counters) { counter.writeToFile(); } } finally { storageLock.release(); } } catch (final IOException e) { LOG.warn("exception while writing counters data to files", e); } finally { try { for (final Counter counter : counters) { counter.clear(); } } finally { if (metricsPublishers != null) { for (final MetricsPublisher metricsPublisher : metricsPublishers) { metricsPublisher.stop(); } } } stopped = true; } } Collector(String application, List<Counter> counters);  Collector(String application, List<Counter> counters,
			SamplingProfiler samplingProfiler); String getApplication(); SamplingProfiler getSamplingProfiler(); List<SampledMethod> getHotspots(); Map<String, Date> getDatesByWebappVersions(); List<Counter> getCounters(); Counter getCounterByName(String counterName); Counter getCounterByRequestId(CounterRequest request); List<CounterRequestContext> getRootCurrentContexts(List<Counter> newParentCounters); long getLastCollectDuration(); Throwable getLastCollectorException(); long getEstimatedMemorySize(); long getDiskUsage(); List<Counter> getRangeCounters(Range range); List<Counter> getRangeCountersToBeDisplayed(Range range); Counter getRangeCounter(Range range, String counterName); void collectLocalContextWithoutErrors(); void collectWithoutErrors(List<JavaInformations> javaInformationsList); JRobin getJRobin(String graphName); Collection<JRobin> getCounterJRobins(); Collection<JRobin> getDisplayedCounterJRobins(); Collection<JRobin> getDisplayedOtherJRobins(); boolean isStorageUsedByMultipleInstances(); void stop(); boolean isStopped(); static void stopJRobin(); static void detachVirtualMachine(); @Override String toString();  }
@Test public void testStop() { final Collector collector = createCollectorWithOneCounter(); collector.stop(); if (collector.getCounters().size() == 0) { fail("collector.getCounters() ne doit pas être vide après stop"); } Collector.detachVirtualMachine(); setProperty(Parameter.STORAGE_DIRECTORY, "/???"); final Counter counter = createCounter(); final Collector collector2 = new Collector("test stop", Collections.singletonList(counter)); counter.addRequest("test stop", 0, 0, 0, false, 1000); collector2 .collectWithoutErrors(Collections.singletonList(new JavaInformations(null, true))); collector2.stop(); setProperty(Parameter.STORAGE_DIRECTORY, "javamelody"); }