You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "jamesfredley (via GitHub)" <gi...@apache.org> on 2026/02/25 17:29:46 UTC
[PR] fix: flaky ersatz listener test due to async race condition [grails-core]
jamesfredley opened a new pull request, #15455:
URL: https://github.com/apache/grails-core/pull/15455
## Summary
- Fixes intermittent failure in `MicronautErsatzAdvancedSpec > ersatz listener captures request details` (seen in [Functional Tests (17) on PR #15420](https://github.com/apache/grails-core/actions/runs/22367572748/job/64752401657))
- The Ersatz listener callback runs asynchronously on a server thread, but the test asserted `captured.size() == 1` immediately - a race condition where the listener hadn't populated the list yet
- Uses `CopyOnWriteArrayList` for thread safety and Spock `PollingConditions` to wait up to 5 seconds for the async listener to complete
## Root Cause
```
captured.size() == 1
| | |
| 0 false
[{ GET /micronaut-test/listen(...) }]
```
The request was received (visible in the toString), but the listener closure `{ captured << it }` hadn't executed yet when the assertion ran. Plain `ArrayList` is also not thread-safe for cross-thread writes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: flaky ersatz listener test due to async race condition [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley merged PR #15455:
URL: https://github.com/apache/grails-core/pull/15455
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org