@Override
    public boolean nextConfig(long timeout) {
        file.validateFile();
        if (checkReloaded()) {
            log.log(FINE, () -> "User forced config reload at " + System.currentTimeMillis());
            // User forced reload
            setConfigIfChanged(updateConfig());
            ConfigState<T> configState = getConfigState();
            log.log(FINE, () -> "Config updated at " + System.currentTimeMillis() + ", changed: " + configState.isConfigChanged());
            log.log(FINE, () -> "Config: " + configState.getConfig().toString());
            return true;
        }
        if (file.getLastModified() != ts) {
            setConfigIncGen(updateConfig());
            return true;
        }
        try {
            Thread.sleep(timeout);
        } catch (InterruptedException e) {
            throw new ConfigInterruptedException(e);
        }

        return false;
    }
@Test
    public void require_that_new_config_is_detected_on_reload() throws IOException {
        writeConfig("intval", "23");
        ConfigSubscription<SimpletypesConfig> sub = new FileConfigSubscription<>(
                new ConfigKey<>(SimpletypesConfig.class, ""),
                new FileSource(TEST_TYPES_FILE));
        assertTrue(sub.nextConfig(1000));
        assertEquals(23, sub.getConfigState().getConfig().intval());
        writeConfig("intval", "33");
        sub.reload(1);
        assertTrue(sub.nextConfig(1000));
        ConfigSubscription.ConfigState<SimpletypesConfig> configState = sub.getConfigState();
        assertEquals(33, configState.getConfig().intval());
        assertTrue(configState.isConfigChanged());
        assertTrue(configState.isGenerationChanged());

        assertTrue(sub.isConfigChangedAndReset(7L));
        assertSame(configState, sub.getConfigState());
        assertTrue(configState.isConfigChanged());
        assertTrue(configState.isGenerationChanged());
        assertTrue(sub.isConfigChangedAndReset(1L));
        assertNotSame(configState, sub.getConfigState());
        configState = sub.getConfigState();
        assertFalse(configState.isConfigChanged());
        assertFalse(configState.isGenerationChanged());

        sub.reload(2);
        assertTrue(sub.nextConfig(1000));
        configState = sub.getConfigState();
        assertEquals(33, configState.getConfig().intval());
        assertFalse(configState.isConfigChanged());
        assertTrue(configState.isGenerationChanged());

        assertFalse(sub.isConfigChangedAndReset(2L));
        assertNotSame(configState, sub.getConfigState());
        configState = sub.getConfigState();
        assertFalse(configState.isConfigChanged());
        assertFalse(configState.isGenerationChanged());
    }