Fix Folia locale string concurrency issue Fixes #5097

This commit is contained in:
nossr50 2024-11-09 14:22:47 -08:00
parent f90a15a821
commit 2ea9cff2cd
2 changed files with 4 additions and 1 deletions

View File

@ -1,4 +1,5 @@
Version 2.2.027 Version 2.2.027
Fixed concurrency issue with Folia regarding locale strings
Version 2.2.026 Version 2.2.026
Fixed NullPointerException on ChunkUnloadEvent Fixed NullPointerException on ChunkUnloadEvent

View File

@ -15,6 +15,7 @@ import java.text.MessageFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -22,7 +23,8 @@ import java.util.regex.Pattern;
public final class LocaleLoader { public final class LocaleLoader {
private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale"; private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale";
private static final String OVERRIDE_FILE_NAME = "locale_override.properties"; private static final String OVERRIDE_FILE_NAME = "locale_override.properties";
private static Map<String, String> bundleCache = new HashMap<>(); // Must be concurrent to accomodate Folia
private static Map<String, String> bundleCache = new ConcurrentHashMap<>();
private static ResourceBundle bundle = null; private static ResourceBundle bundle = null;
private static ResourceBundle filesystemBundle = null; private static ResourceBundle filesystemBundle = null;
private static ResourceBundle enBundle = null; private static ResourceBundle enBundle = null;