Commit fda4d0a
Fix race in AsyncPollerTest.testSuspendPolling
The test relied on the poller's second iteration racing past its
suspend-latch check before the test thread called suspendPolling(). If
the test thread won the race, iter 2 blocked at the suspend latch and
never reached reserveSlot — so reservedCount stayed at 1 and the later
`expected:<2> but was:<1>` assertion failed. Bumping the assertEventually
timeout didn't help; the race either wins or loses deterministically on
a given run.
Remove the race: override reserveSlot on the slot supplier to count
invocations, and wait for reserveCalls == 2 before suspending. That's a
direct signal that iter 2 has passed the suspend check and called
reserveSlot (its future can't complete until iter 1's slot is released,
but the call itself happens immediately). After this signal, iter 2 is
pinned past the suspend check, so the subsequent suspendPolling() only
affects iter 3+.
Also drop the now-redundant first assertEventually: once pollLatch
counts down (inside the mocked poll()), iter 1's slot has already been
issued, so reservedCount == 1 is synchronously visible.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b6f4283 commit fda4d0a
1 file changed
Lines changed: 21 additions & 10 deletions
Lines changed: 21 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
340 | 348 | | |
341 | 349 | | |
342 | 350 | | |
| |||
370 | 378 | | |
371 | 379 | | |
372 | 380 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
381 | 392 | | |
382 | 393 | | |
383 | 394 | | |
384 | | - | |
| 395 | + | |
385 | 396 | | |
386 | 397 | | |
387 | 398 | | |
| |||
0 commit comments