From 0016f4ce1972a8b7f3dc5862677e69edd2569654 Mon Sep 17 00:00:00 2001 From: A248 Date: Mon, 22 Mar 2021 08:11:25 -0400 Subject: [PATCH] Relay more exceptions (#446) --- .../connection/backend/TransitionSessionHandler.java | 2 +- .../proxy/connection/client/ConnectedPlayer.java | 10 ++++++++-- .../proxy/protocol/netty/GS4QueryHandler.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java index ff3f56026..f127abe25 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java @@ -86,7 +86,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler { server.getEventManager() .fire(new ServerConnectedEvent(player, serverConn.getServer(), existingConnection != null ? existingConnection.getServer() : null)) - .whenCompleteAsync((x, error) -> { + .thenRunAsync(() -> { // Make sure we can still transition (player might have disconnected here). if (!serverConn.isActive()) { // Connection is obsolete. 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 949243e17..3cc40dfcb 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 @@ -1000,8 +1000,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { VelocityServerConnection con = new VelocityServerConnection(vrs, ConnectedPlayer.this, server); connectionInFlight = con; - return con.connect().whenCompleteAsync((result, throwable) -> - this.resetIfInFlightIs(con), connection.eventLoop()); + return con.connect().thenApplyAsync((result) -> { + this.resetIfInFlightIs(con); + return result; + }, connection.eventLoop()); }, connection.eventLoop()); }); } @@ -1019,8 +1021,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { if (status != null && !status.isSuccessful()) { if (!status.isSafe()) { handleConnectionException(status.getAttemptedConnection(), throwable, false); + return; } } + if (throwable != null) { + logger.error("Exception during connect; status = {}", status, throwable); + } }, connection.eventLoop()) .thenApply(x -> x); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java index ffe2a24b4..287de50aa 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java @@ -134,7 +134,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler // Call event and write response server.getEventManager() .fire(new ProxyQueryEvent(isBasic ? BASIC : FULL, senderAddress, response)) - .whenCompleteAsync((event, exc) -> { + .thenAcceptAsync((event) -> { // Packet header ByteBuf queryResponse = ctx.alloc().buffer(); queryResponse.writeByte(QUERY_TYPE_STAT);