From 101d8c72750b5d4b447a982982153ab2ded1e506 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sat, 28 Jun 2025 21:40:43 +0700 Subject: [PATCH] [FIX] Probably fix access profileMap with multiple threads --- .../launchserver/auth/profiles/LocalProfilesProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java index 6883818f..cd5faec3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/profiles/LocalProfilesProvider.java @@ -23,6 +23,7 @@ import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; public class LocalProfilesProvider extends ProfilesProvider implements Reconfigurable { @@ -196,7 +197,7 @@ private void readCache(Path file) throws IOException { public void readProfilesDir() throws IOException { Path profilesDirPath = Path.of(profilesDir); - Map newProfiles = new HashMap<>(); + Map newProfiles = new ConcurrentHashMap<>(); IOHelper.walk(profilesDirPath, new ProfilesFileVisitor(newProfiles), false); profilesMap = newProfiles; } @@ -218,7 +219,7 @@ public void readUpdatesDir() throws IOException { public void sync(Collection dirs) throws IOException { logger.info("Syncing updates dir"); - Map newUpdatesDirMap = new HashMap<>(16); + Map newUpdatesDirMap = new ConcurrentHashMap<>(16); try (DirectoryStream dirStream = Files.newDirectoryStream(Path.of(updatesDir))) { for (final Path updateDir : dirStream) { if (Files.isHidden(updateDir))