From 669bd14779f9e673afc852e5a6d7ba1380035964 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 3 Jun 2020 12:18:29 -0400 Subject: [PATCH] Remove duplicate in-flight connection reset --- .../proxy/connection/backend/VelocityServerConnection.java | 4 +--- .../proxy/connection/client/ConnectedPlayer.java | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index 86a17870d..453faa0dc 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -84,9 +84,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, connectionPhase = connection.getType().getInitialBackendPhase(); startHandshake(); } else { - // We need to remember to reset the in-flight connection to allow connect() to work - // properly. - proxyPlayer.resetInFlightConnection(); + // Complete the result immediately. ConnectedPlayer will reset the in-flight connection. result.completeExceptionally(future.cause()); } }); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 5f550e5a0..95cbdefb8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -758,12 +758,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { ConnectedPlayer.this, server); connectionInFlight = con; return con.connect().whenCompleteAsync((result, throwable) -> - this.cleanupIfRequired(con), connection.eventLoop()); + this.resetIfInFlightIs(con), connection.eventLoop()); }, connection.eventLoop()); }); } - private void cleanupIfRequired(VelocityServerConnection establishedConnection) { + private void resetIfInFlightIs(VelocityServerConnection establishedConnection) { if (establishedConnection == connectionInFlight) { resetInFlightConnection(); }