@Override
    public void addConfigListener(String dataId, ConfigurationChangeListener listener) {
        if (StringUtils.isBlank(dataId) || listener == null) {
            return;
        }
        configListenersMap.computeIfAbsent(dataId, key -> ConcurrentHashMap.newKeySet())
                .add(listener);
        listenedConfigMap.put(dataId, ConfigurationFactory.getInstance().getConfig(dataId));

        // Start config change listener for the dataId.
        fileListener.addListener(dataId, listener);
    }
@Test
    void addConfigListener() throws InterruptedException {
        logger.info("addConfigListener");
        ConfigurationFactory.reload();
        Configuration fileConfig = ConfigurationFactory.getInstance();
        CountDownLatch countDownLatch = new CountDownLatch(1);
        String dataId = "service.disableGlobalTransaction";
        boolean value = fileConfig.getBoolean(dataId);
        fileConfig.addConfigListener(dataId, (CachedConfigurationChangeListener)event -> {
            logger.info("before dataId: {}, oldValue: {}, newValue: {}", event.getDataId(), event.getOldValue(),
                event.getNewValue());
            Assertions.assertEquals(Boolean.parseBoolean(event.getNewValue()),
                !Boolean.parseBoolean(event.getOldValue()));
            logger.info("after dataId: {}, oldValue: {}, newValue: {}", event.getDataId(), event.getOldValue(),
                event.getNewValue());
            countDownLatch.countDown();
        });
        System.setProperty(dataId, String.valueOf(!value));
        logger.info(System.currentTimeMillis()+", dataId: {}, oldValue: {}", dataId, value);
        countDownLatch.await(60,TimeUnit.SECONDS);
        logger.info(System.currentTimeMillis()+", dataId: {}, currenValue: {}", dataId, fileConfig.getBoolean(dataId));
        Assertions.assertNotEquals(fileConfig.getBoolean(dataId), value);
        //wait for loop safety, loop time is LISTENER_CONFIG_INTERVAL=1s
        CountDownLatch countDownLatch2 = new CountDownLatch(1);
        fileConfig.addConfigListener("file.listener.enabled", (CachedConfigurationChangeListener)event -> {
            if (!Boolean.parseBoolean(event.getNewValue())) {
                countDownLatch2.countDown();
            }
        });
        System.setProperty("file.listener.enabled", "false");
        countDownLatch2.await(10, TimeUnit.SECONDS);
        System.setProperty(dataId, String.valueOf(value));
        //sleep for a period of time to simulate waiting for a cache refresh.Actually, it doesn't trigger.
        Thread.sleep(1000);

        boolean currentValue = fileConfig.getBoolean(dataId);
        Assertions.assertNotEquals(value, currentValue);
        System.setProperty(dataId, String.valueOf(!value));
    }