@Override
    public Snapshot getSnapshot() {
        rescaleIfNeeded();
        lockForRegularUsage();
        try {
            return new WeightedSnapshot(values.values());
        } finally {
            unlockForRegularUsage();
        }
    }
@Test
    public void removeZeroWeightsInSamplesToPreventNaNInMeanValues() {
        final ManualClock clock = new ManualClock();
        final Reservoir reservoir = reservoirFactory.create(1028, 0.015, clock);
        Timer timer = new Timer(reservoir, clock);

        Context context = timer.time();
        clock.addMillis(100);
        context.stop();

        for (int i = 1; i < 48; i++) {
            clock.addHours(1);
            assertThat(reservoir.getSnapshot().getMean()).isBetween(0.0, Double.MAX_VALUE);
        }
    }