From 39324ce95dca8e16c2229f34d5c77a7c2c901242 Mon Sep 17 00:00:00 2001 From: Redned Date: Sun, 18 Jul 2021 17:41:47 -0500 Subject: [PATCH] Go back to normal thread for now using MSA auth, and only toggle leak detector on standalone --- .../java/org/geysermc/connector/GeyserConnector.java | 2 +- .../connector/network/session/GeyserSession.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 98dfbc5ce..107a48c4d 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -126,7 +126,7 @@ public class GeyserConnector { private Metrics metrics; private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) { - if (System.getProperty("io.netty.leakDetection.level") == null) { + if (platformType == PlatformType.STANDALONE && System.getProperty("io.netty.leakDetection.level") == null) { ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); // Can eat performance } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 0daf15b60..f9ae137bf 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -609,10 +609,8 @@ public class GeyserSession implements CommandSender { } loggingIn = true; - - // Use a future to prevent timeouts as all the authentication is handled sync - // This will be changed with the new protocol library. - CompletableFuture.supplyAsync(() -> { + // new thread so clients don't timeout + new Thread(() -> { try { MsaAuthenticationService msaAuthenticationService = new MsaAuthenticationService(GeyserConnector.OAUTH_CLIENT_ID); @@ -632,8 +630,7 @@ public class GeyserSession implements CommandSender { } catch (RequestException ex) { ex.printStackTrace(); } - return null; - }).whenComplete((aVoid, ex) -> connectDownstream()); + }).start(); } /** @@ -650,7 +647,7 @@ public class GeyserSession implements CommandSender { connectDownstream(); } catch (RequestException e) { if (!(e instanceof AuthPendingException)) { - e.printStackTrace(); + throw new RuntimeException("Failed to log in with Microsoft code!", e); } else { // Wait one second before trying again connector.getGeneralThreadPool().schedule(() -> attemptCodeAuthentication(msaAuthenticationService), 1, TimeUnit.SECONDS);