GH-1789 - Use ConcurrentHashMap for the module dependency cache. - #1790
Open
arendomoda wants to merge 2 commits into
Open
GH-1789 - Use ConcurrentHashMap for the module dependency cache.#1790arendomoda wants to merge 2 commits into
arendomoda wants to merge 2 commits into
Conversation
…ncy cache. Fixes spring-projects#1789 `TestExecutionCondition.evaluate(…)` is called concurrently when `junit.jupiter.execution.parallel.mode.classes.default=concurrent` is configured, so `computeIfAbsent` on the plain `HashMap` can fail with a `ConcurrentModificationException`. Switching to `ConcurrentHashMap` keeps the caching behaviour and makes the field safe for concurrent access; `ApplicationModule.getAllDependencies(…)` never returns `null`, so the map's null-hostility is not a concern. Observed on 2.0.6 with 74 of 602 test classes failing per run (different classes each time). No regression test added: reproducing the race deterministically isn't practical. Happy to add a stress test if you'd prefer one. Signed-off-by: arendomoda <arend.vanerk@omoda.nl>
Signed-off-by: arendomoda <arend.vanerk@omoda.nl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1789
TestExecutionCondition.evaluate(…)is called concurrently whenjunit.jupiter.execution.parallel.mode.classes.default=concurrentis configured, socomputeIfAbsenton the plainHashMapcan fail with aConcurrentModificationException. Switching toConcurrentHashMapkeeps the caching behaviour and makes the field safe for concurrent access;ApplicationModule.getAllDependencies(…)never returnsnull, so the map's null-hostility is not a concern.Observed on 2.0.6 with 74 of 602 test classes failing per run (different classes each time). No regression test added: reproducing the race deterministically isn't practical. Happy to add a stress test if you'd prefer one.
Signed-off-by: Arend van Erk arend.vanerk@omoda.nl