This is an automated email from the ASF dual-hosted git repository.

Bughue pushed a commit to branch 2.7.0
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.7.0 by this push:
     new 49fef81747 test: fix flaky testCachedConfigurationChangeListener on 
2.7.0 (#8184)
49fef81747 is described below

commit 49fef81747c3f7afd9ec0ae054e5a4aece83e5ac
Author: justabug <[email protected]>
AuthorDate: Sat Jul 25 20:36:59 2026 +0800

    test: fix flaky testCachedConfigurationChangeListener on 2.7.0 (#8184)
    
    * test: fix flaky testCachedConfigurationChangeListener on 2.7.0
    
    Backport of #8175: wait for async callback with CountDownLatch to avoid
    race that failed most ubuntu/druid CI jobs after #8166.
    
    * docs: reference PR #8184 in 2.7.0 changelog
---
 changes/en-us/2.7.0.md                                             | 1 +
 changes/zh-cn/2.7.0.md                                             | 1 +
 .../org/apache/seata/config/ConfigurationChangeListenerTest.java   | 7 ++++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/changes/en-us/2.7.0.md b/changes/en-us/2.7.0.md
index 435ec1c935..fefa102adc 100644
--- a/changes/en-us/2.7.0.md
+++ b/changes/en-us/2.7.0.md
@@ -101,6 +101,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#7915](https://github.com/apache/incubator-seata/pull/7915)] add unit 
tests for saga-engine module
 - [[#8051](https://github.com/apache/incubator-seata/pull/8051)] isolate 
compatibility tests from transport protocol interference
 - [[#8123](https://github.com/apache/incubator-seata/pull/8123)] add 
integration tx api mock tests
+- [[#8184](https://github.com/apache/incubator-seata/pull/8184)] fix flaky 
testCachedConfigurationChangeListener due to async race condition (backport 
#8175)
 
 ### refactor:
 
diff --git a/changes/zh-cn/2.7.0.md b/changes/zh-cn/2.7.0.md
index 0315ce3c20..647243acfc 100644
--- a/changes/zh-cn/2.7.0.md
+++ b/changes/zh-cn/2.7.0.md
@@ -103,6 +103,7 @@
 - [[#7915](https://github.com/apache/incubator-seata/pull/7915)] 为 saga-engine 
模块添加单元测试
 - [[#8051](https://github.com/apache/incubator-seata/pull/8051)] 
隔离兼容性测试与传输协议的干扰
 - [[#8123](https://github.com/apache/incubator-seata/pull/8123)] 
为integration-tx-api模块添加测试
+- [[#8184](https://github.com/apache/incubator-seata/pull/8184)] 修复 
testCachedConfigurationChangeListener 因异步竞态条件导致的偶发失败(backport #8175)
 
 
 ### 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]

Reply via email to