Commit 4a6da86
committed
CountDownLatch Synchronization for RCPTestWorkbenchAdvisor
The flaky test was caused by a race condition in
RCPTestWorkbenchAdvisor.java. The test spawns 4 background threads
during preStartup() that schedule async/sync runnables on the display.
However, there was no guarantee these runnables would execute before
postStartup() marked the workbench as "started" (by setting started =
true).
This meant asyncWithDisplayAccess could still be null when the test
assertions ran, causing intermittent failures.
This change adds a CountDownLatch to ensure all 4 async/sync operations
complete before marking the workbench as started:
Key changes to
/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/RCPTestWorkbenchAdvisor.java:
1. Added latch field (line 48):
- private static java.util.concurrent.CountDownLatch asyncLatch =
null;
2. Initialize latch in preStartup() (line 130):
- asyncLatch = new java.util.concurrent.CountDownLatch(4); — tracks
4 operations
3. Count down after each operation completes:
- In setupSyncDisplayThread(): Added finally block (lines 179-183)
that calls asyncLatch.countDown()
- In setupAsyncDisplayThread(): Added finally block (lines 205-209)
that calls asyncLatch.countDown()
4. Wait for operations in postStartup() (lines 222-235):
- Waits up to 5 seconds for all operations to complete
- Logs warnings if timeout occurs or thread is interrupted
- Only marks started = true after all operations complete
Fixes #15171 parent e900fff commit 4a6da86
File tree
1 file changed
+40
-5
lines changed- tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util
1 file changed
+40
-5
lines changedLines changed: 40 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
| |||
169 | 176 | | |
170 | 177 | | |
171 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
172 | 184 | | |
173 | 185 | | |
174 | 186 | | |
| |||
183 | 195 | | |
184 | 196 | | |
185 | 197 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
191 | 210 | | |
192 | 211 | | |
193 | 212 | | |
| |||
199 | 218 | | |
200 | 219 | | |
201 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
202 | 237 | | |
203 | 238 | | |
204 | 239 | | |
| |||
0 commit comments