From 8e0ca2033ea80016f333442ad14d40a7ef8f0215 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 26 Aug 2018 22:43:18 -0400 Subject: [PATCH] Explicitly cover unexpected disconnects during login --- .../proxy/connection/backend/LoginSessionHandler.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java index cd0513582..feb28ee2e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java @@ -20,6 +20,7 @@ import net.kyori.text.TextComponent; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; +import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.CompletableFuture; @@ -100,6 +101,15 @@ public class LoginSessionHandler implements MinecraftSessionHandler { } } + @Override + public void disconnected() { + CompletableFuture future = connection.getMinecraftConnection().getChannel() + .attr(VelocityServerConnection.CONNECTION_NOTIFIER).getAndSet(null); + if (future != null) { + future.completeExceptionally(new IOException("Unexpectedly disconnected from remote server")); + } + } + private void doNotify(ConnectionRequestBuilder.Result result) { CompletableFuture future = connection.getMinecraftConnection().getChannel() .attr(VelocityServerConnection.CONNECTION_NOTIFIER).getAndSet(null);