From 62c8ca878e598bb8e001fc608e33aa54352a3d33 Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 17 Dec 2020 01:39:24 +0700 Subject: [PATCH] [FIX] SessionStorage NPE --- .../java/pro/gravit/launchserver/LaunchServerStarter.java | 2 ++ .../gravit/launchserver/auth/session/SessionStorage.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index 7e012dfe..8c49e94b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -10,6 +10,7 @@ import pro.gravit.launchserver.auth.protect.ProtectHandler; import pro.gravit.launchserver.auth.protect.hwid.HWIDProvider; import pro.gravit.launchserver.auth.provider.AuthProvider; +import pro.gravit.launchserver.auth.session.SessionStorage; import pro.gravit.launchserver.auth.texture.TextureProvider; import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.config.LaunchServerConfig; @@ -215,6 +216,7 @@ public static void registerAll() { AuthRequest.registerProviders(); HWIDProvider.registerProviders(); OptionalAction.registerProviders(); + SessionStorage.registerProviders(); } public static void generateConfigIfNotExists(Path configFile, CommandHandler commandHandler, LaunchServer.LaunchServerEnv env) throws IOException { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/SessionStorage.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/SessionStorage.java index 463b7a60..e576c07f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/SessionStorage.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/session/SessionStorage.java @@ -10,6 +10,7 @@ public abstract class SessionStorage { protected transient LaunchServer server; public static ProviderMap providers = new ProviderMap<>(); + private static boolean registeredProviders = false; public abstract byte[] getSessionData(UUID session); public abstract Stream getSessionsFromUserUUID(UUID userUUID); public abstract boolean writeSession(UUID userUUID, UUID sessionUUID, byte[] data); @@ -23,4 +24,10 @@ public void init(LaunchServer server) { this.server = server; } + public static void registerProviders() { + if(!registeredProviders) { + providers.register("memory", MemorySessionStorage.class); + registeredProviders = true; + } + } }