From 2ea9cff2cd870df6dcf0018fe4c3b2b0f172bd01 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 9 Nov 2024 14:22:47 -0800 Subject: [PATCH] Fix Folia locale string concurrency issue Fixes #5097 --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/locale/LocaleLoader.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 0a6e85d4e..08417ade1 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,5 @@ Version 2.2.027 + Fixed concurrency issue with Folia regarding locale strings Version 2.2.026 Fixed NullPointerException on ChunkUnloadEvent diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java index 81ab06625..d65cf6404 100644 --- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java +++ b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java @@ -15,6 +15,7 @@ import java.text.MessageFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -22,7 +23,8 @@ import java.util.regex.Pattern; public final class LocaleLoader { private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale"; private static final String OVERRIDE_FILE_NAME = "locale_override.properties"; - private static Map bundleCache = new HashMap<>(); + // Must be concurrent to accomodate Folia + private static Map bundleCache = new ConcurrentHashMap<>(); private static ResourceBundle bundle = null; private static ResourceBundle filesystemBundle = null; private static ResourceBundle enBundle = null;