Commit 46664e9
committed
Fix race condition in WanCopyRegionFunctionServiceTest
The test severalExecuteWithDifferentRegionOrSenderAreAllowed was failing
intermittently with 'expected: 5 but was: 3' due to a race condition.
The test creates 5 CompletableFuture tasks using supplyAsync(), but there
was no guarantee that all tasks would start executing before the assertion
checked the execution count.
Solution:
- Added a startLatch CountDownLatch to synchronize task startup
- Each callable now counts down the startLatch when it begins execution
- The test waits for all tasks to start before asserting on the count
- Added throws InterruptedException to the test method signature
This ensures all 5 tasks have called service.execute() and been added to
the executions map before we verify the count, eliminating the race
condition.1 parent 9f776b9 commit 46664e9
1 file changed
Lines changed: 6 additions & 1 deletion
File tree
- geode-wan/src/test/java/org/apache/geode/cache/wan/internal
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
| 163 | + | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| |||
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
| |||
0 commit comments