Fix ConcurrentModificationException on mass Ant project open.#7989
Merged
mbien merged 1 commit intoapache:masterfrom Dec 1, 2024
Merged
Fix ConcurrentModificationException on mass Ant project open.#7989mbien merged 1 commit intoapache:masterfrom
mbien merged 1 commit intoapache:masterfrom
Conversation
Evaluators synchronize their inner workings on a per-instance basis. The static cache however is shared between instances and should use a sharable collection. ConcurrentHashMap is probably the best choice here, since the potentially long running computeIfAbsent would only lock the item, not the map.
mbien
commented
Nov 25, 2024
Comment on lines
+893
to
899
| /** | ||
| * cache shared between Evaluator instances. | ||
| */ | ||
| private static final Map<String, String> limitModulesCache = new ConcurrentHashMap<>(); | ||
|
|
||
| private static String getLimitModules(String javacRelease) { | ||
| return limitModulesCache.computeIfAbsent(javacRelease, release -> { |
Member
Author
There was a problem hiding this comment.
on second thought: this probably could be a plain old synchronized map? The keys are javac release versions, so it won't use the per-item lock feature of the CMH very often.
matthiasblaesing
approved these changes
Nov 29, 2024
Contributor
matthiasblaesing
left a comment
There was a problem hiding this comment.
To me this looks sane as is. If I'm not mistaken, the map should quickly become read-only (all values are cached). I would expect this to be more performant on a ConcurrentHashMap. But I think it does not mapper to much.
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.
Evaluators synchronize their inner workings on a per-instance basis. The static cache however is shared between instances and should use a sharable collection.
ConcurrentHashMapis probably the best choice here, since the potentially long runningcomputeIfAbsentwould only lock the item, not the map. (although in practice it probably doesn't have enough keys to leverage this feature)Exception during NB startup while it is trying to open ~100 NB modules
Details