@Override
    public long read() {
        return gaugeSource.read();
    }
@Test
    public void whenCacheDynamicMetricSourceGcdReadsDefault() {
        NullableDynamicMetricsProvider metricsProvider = new NullableDynamicMetricsProvider();
        WeakReference<SomeObject> someObjectWeakRef = new WeakReference<>(metricsProvider.someObject);
        metricsProvider.someObject.longField = 42;
        metricsRegistry.registerDynamicMetricsProvider(metricsProvider);
        LongGaugeImpl longGauge = metricsRegistry.newLongGauge("foo.longField");

        // needed to collect dynamic metrics and update the gauge created from them
        metricsRegistry.collect(mock(MetricsCollector.class));
        assertEquals(42, longGauge.read());

        metricsProvider.someObject = null;
        System.gc();
        // wait for someObject to get GCd - should have already happened
        assertTrueEventually(() -> assertNull(someObjectWeakRef.get()));

        assertEquals(LongGaugeImpl.DEFAULT_VALUE, longGauge.read());
    }