diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dd1bef4d..a3c144013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,4 @@ - [fix:fix PolarisContextProperties instantiated twice causing NPE.](https://github.com/Tencent/spring-cloud-tencent/pull/1638) - [feat: support tsf 2024.](https://github.com/Tencent/spring-cloud-tencent/pull/1635) - [fix: fix ConfigChangeListener and unit test](https://github.com/Tencent/spring-cloud-tencent/pull/1657) +- [fix: fix ConfigChangeListener ut bug](https://github.com/Tencent/spring-cloud-tencent/pull/1663) diff --git a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/listener/ConfigChangeListenerTest.java b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/listener/ConfigChangeListenerTest.java index 6898bb331..1d6e70ef9 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/listener/ConfigChangeListenerTest.java +++ b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/listener/ConfigChangeListenerTest.java @@ -57,7 +57,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen }) public class ConfigChangeListenerTest { - private static final CountDownLatch hits = new CountDownLatch(2); + private static CountDownLatch hits = new CountDownLatch(2); @Autowired private ApplicationEventPublisher applicationEventPublisher; @Autowired @@ -90,8 +90,10 @@ public class ConfigChangeListenerTest { EnvironmentChangeEvent event = new EnvironmentChangeEvent(applicationContext, ketSet); applicationEventPublisher.publishEvent(event); //after change + //Reset hits for each iteration boolean ret = hits.await(2, TimeUnit.SECONDS); Assertions.assertThat(ret).isEqualTo(true); + hits = new CountDownLatch(2); Assertions.assertThat(testConfig.getChangeCnt()).isEqualTo(2 * i - 2); Assertions.assertThat(testConfig.getSyncChangeCnt()).isEqualTo(2 * i - 2); Assertions.assertThat(testConfig.getTimeout()).isEqualTo(i * 1000);