Repository navigation
Make XP formula caches safe for concurrent access - #5348
Open
cyrne1-7208 wants to merge 1 commit into
Open
cyrne1-7208 wants to merge 1 commit into
cyrne1-7208 wants to merge 1 commit into
Conversation
Contributor
Author
|
I forgot to add comments to the test code ( ; ; ) |
cyrne1-7208
force-pushed
the
fix/folia-xp-cache-concurrency
branch
from
September 23, 2026 09:17
24c446f to
3b1123e
Compare
cyrne1-7208
marked this pull request as draft
October 8, 2026 03:52
FormulaManager fills its XP requirement caches lazily with computeIfAbsent on plain HashMaps. On Folia, players level up on several region threads at once, and placeholders such as %mcmmo_xp_needed_<skill>% can be requested off the main thread on any platform, so concurrent writes could corrupt a map or make computeIfAbsent throw ConcurrentModificationException. The caches are now final ConcurrentMaps backed by ConcurrentHashMap. Signed-off-by: Cyrne1_7208 <127477265+cyrne1-7208@users.noreply.github.com>
cyrne1-7208
force-pushed
the
fix/folia-xp-cache-concurrency
branch
from
October 8, 2026 05:19
3b1123e to
eb9c0ff
Compare
cyrne1-7208
marked this pull request as ready for review
October 8, 2026 05:27
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.
Summary
FormulaManagerfills its four XP requirement caches lazily withcomputeIfAbsenton plainHashMaps. On Folia, players level up on different region threads at the same time, and on any platform placeholders such as%mcmmo_xp_needed_<skill>%can be requested off the main thread. Concurrent writes can corrupt aHashMapor makecomputeIfAbsentthrowConcurrentModificationException.Changes
ConcurrentMaps backed byConcurrentHashMap, and removeinitExperienceNeededMaps().No test is added. The XP math reads the
mcMMOandExperienceConfigstatics, and Mockito static mocks only apply on the thread that created them, so a test with several threads would not run against the mocks.Testing
mvn test: all tests pass.