This is an automated email from the ASF dual-hosted git repository.
funky-eyes pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push:
new f97462e9e7 test: fix laky testCachedConfigurationChangeListener due to
async race condition (#8175)
f97462e9e7 is described below
commit f97462e9e770a9d6cef710a2c64c3460f8b78776
Author: 徐晓伟 <[email protected]>
AuthorDate: Fri Jul 24 09:34:17 2026 +0800
test: fix laky testCachedConfigurationChangeListener due to async race
condition (#8175)
---
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
.../org/apache/seata/config/ConfigurationChangeListenerTest.java | 7 ++++++-
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 9070b7d4aa..4a1015b2af 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -41,6 +41,7 @@ Add changes here for all PR submitted to the 2.x branch.
### test:
- [[#8146](https://github.com/apache/incubator-seata/pull/8146)] test: cover
rm-datasource resource id initializers
+- [[#8175](https://github.com/apache/incubator-seata/pull/8175)] fix flaky
testCachedConfigurationChangeListener due to async race condition
### refactor:
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 255f14c622..63cdd6c1ba 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -40,6 +40,7 @@
### test:
- [[#8146](https://github.com/apache/incubator-seata/pull/8146)] test: 覆盖
rm-datasource resource id initializers
+- [[#8175](https://github.com/apache/incubator-seata/pull/8175)] 修复
testCachedConfigurationChangeListener 因异步竞态条件导致的偶发失败
### refactor:
diff --git
a/config/seata-config-core/src/test/java/org/apache/seata/config/ConfigurationChangeListenerTest.java
b/config/seata-config-core/src/test/java/org/apache/seata/config/ConfigurationChangeListenerTest.java
index 4d2a77e25c..a8d839dc1a 100644
---
a/config/seata-config-core/src/test/java/org/apache/seata/config/ConfigurationChangeListenerTest.java
+++
b/config/seata-config-core/src/test/java/org/apache/seata/config/ConfigurationChangeListenerTest.java
@@ -19,8 +19,10 @@ package org.apache.seata.config;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -216,12 +218,14 @@ class ConfigurationChangeListenerTest {
}
@Test
- void testCachedConfigurationChangeListener() {
+ void testCachedConfigurationChangeListener() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
AtomicBoolean changeEventCalled = new AtomicBoolean(false);
CachedConfigurationChangeListener listener = new
CachedConfigurationChangeListener() {
@Override
public void onChangeEvent(ConfigurationChangeEvent event) {
changeEventCalled.set(true);
+ latch.countDown();
}
};
@@ -231,6 +235,7 @@ class ConfigurationChangeListenerTest {
try {
listener.onProcessEvent(event);
+ latch.await(5, TimeUnit.SECONDS);
Assertions.assertTrue(changeEventCalled.get());
} catch (Exception e) {
// ignore executor service related exceptions
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]