Skip to content

Commit 7d68208

Browse files
Always close HttpClient (#1798)
* Always close HttpClient (even on exception) * Get rid of try/catch since we now use java 21
1 parent 38ff21a commit 7d68208

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,8 @@ public boolean handle(EncryptionResponsePacket packet) {
268268
inbound.disconnect(Component.translatable("multiplayer.disconnect.authservers_down"));
269269
}
270270
}, mcConnection.eventLoop())
271-
.thenRun(() -> {
272-
try {
273-
httpClient.close();
274-
} catch (Exception e) {
275-
// In Java 21, the HttpClient does not throw any Exception
276-
// when trying to clean its resources, so this should not happen
277-
logger.error("An unknown error occurred while trying to close an HttpClient", e);
278-
}
271+
.whenComplete((ignored, throwable) -> {
272+
httpClient.close();
279273
});
280274
} catch (GeneralSecurityException e) {
281275
logger.error("Unable to enable encryption", e);

0 commit comments

Comments
 (0)