Always close HttpClient (#1798)

* Always close HttpClient (even on exception)

* Get rid of try/catch since we now use java 21
This commit is contained in:
Wouter Gritter
2026-05-22 17:25:48 +02:00
committed by GitHub
parent 38ff21afd7
commit 7d68208e11

View File

@@ -268,14 +268,8 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
inbound.disconnect(Component.translatable("multiplayer.disconnect.authservers_down"));
}
}, mcConnection.eventLoop())
.thenRun(() -> {
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);
}
.whenComplete((ignored, throwable) -> {
httpClient.close();
});
} catch (GeneralSecurityException e) {
logger.error("Unable to enable encryption", e);