From 2019723592dd2d59c89c9c50fa7e422457bf26f8 Mon Sep 17 00:00:00 2001 From: Wouter Gritter Date: Thu, 21 May 2026 22:54:23 +0200 Subject: [PATCH 1/2] Always close HttpClient (even on exception) --- .../proxy/connection/client/InitialLoginSessionHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java index 482fb76e64..e827bbcccd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java @@ -268,7 +268,7 @@ public boolean handle(EncryptionResponsePacket packet) { inbound.disconnect(Component.translatable("multiplayer.disconnect.authservers_down")); } }, mcConnection.eventLoop()) - .thenRun(() -> { + .whenComplete((ignored, throwable) -> { try { httpClient.close(); } catch (Exception e) { From 396b88888a9c9c071d795825ae6518d365870918 Mon Sep 17 00:00:00 2001 From: Wouter Gritter Date: Fri, 22 May 2026 16:00:47 +0200 Subject: [PATCH 2/2] Get rid of try/catch since we now use java 21 --- .../connection/client/InitialLoginSessionHandler.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java index e827bbcccd..f6e1cd6e1d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java @@ -269,13 +269,7 @@ public boolean handle(EncryptionResponsePacket packet) { } }, mcConnection.eventLoop()) .whenComplete((ignored, throwable) -> { - try { - httpClient.close(); - } catch (Exception e) { - // In Java 21, the HttpClient does not throw any Exception - // when trying to clean its resources, so this should not happen - logger.error("An unknown error occurred while trying to close an HttpClient", e); - } + httpClient.close(); }); } catch (GeneralSecurityException e) { logger.error("Unable to enable encryption", e);