@Override
    public double read() {
        return gaugeSource.read();
    }
@Test
    public void whenCacheDynamicMetricSourceGcdReadsDefault() {
        NullableDynamicMetricsProvider metricsProvider = new NullableDynamicMetricsProvider();
        WeakReference<SomeObject> someObjectWeakRef = new WeakReference<>(metricsProvider.someObject);
        metricsProvider.someObject.doubleField = 42.42D;
        metricsRegistry.registerDynamicMetricsProvider(metricsProvider);
        DoubleGauge doubleGauge = metricsRegistry.newDoubleGauge("foo.doubleField");

        // needed to collect dynamic metrics and update the gauge created from them
        metricsRegistry.collect(mock(MetricsCollector.class));
        assertEquals(42.42D, doubleGauge.read(), 10E-6);

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

        assertEquals(DoubleGaugeImpl.DEFAULT_VALUE, doubleGauge.read(), 10E-6);
    }