-
-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intermittent NullPointerException accessing StepEventBus.registeredListeners running concurrently with Cucumber 7 + JUnit 5 Platform #3540
Comments
I've seen this sometimes but never been able to reproduce it. The step event bus is designed to be threadsafe - I can only assume there is a case where it isn't. The test case is a good start. You may be onto something regarding the registeredListeners list. |
If StepEventBus is intended to be thread-safe without external synchronization then should we switch to CopyOnWriteArrayList? Also, I believe this problem gets worse with dozens of Happy to assist with a PR with some guidance 🙂 |
CopyOnWrite is definitely worth a try. I don't recall what the RestListener does, it may not be required any more, in which case we can certainly remove it. |
…3540) to alleviate a race condition iterating and deleting listeners concurrently
since it no longer does anything
Not technically related to this issue, but I've also raised #3544 to avoid creating |
Thanks for the PR reviews so far. There's one more PR outstanding, #3543, that should reduce concurrent operations on |
since it no longer does anything Co-authored-by: James Shaw <[email protected]>
I have a pipeline running Serenity every 30 minutes and I've seen no further occurrences of this bug over the last few days since 4.2.3 was released. |
What happened?
I've occasionally seen two similar stacktraces:
Cucumber/JUnit parallel execution is enabled with
cucumber.execution.parallel.enabled=true
. TheSerenityReporterParallel
is configured.What did you expect to happen?
Tests to complete successfully.
Serenity BDD version
4.21
JDK version
21.0.4
Execution environment
Reproduced on MacOS and Linux, no web browser.
How to reproduce the bug.
I've struggled to reproduce this locally with an entire Serenity/Cucumber test run but I have reproduced with a minimal Kotlin code that accesses and modifies
StepEventBus
concurrently:which soon crashes with:
What I know so far
StepEventBus.registeredListeners
is anArrayList
, meaning external synchronization is needed for concurrent access/modification.StepEventBus
is shared between all scenarios in a feature file (seeSerenityReporterParallel.getStepEventBus(URI)
), and Cucumber/JUnit 5 Platform runs scenarios in parallel.But I've yet to pin down the exact behaviour that triggers concurrent access/modification.
How can we make it happen?
Work on this myself and propose a PR (with Serenity BDD team guidance)
The text was updated successfully, but these errors were encountered: