13
0
geforkt von Mirrors/Velocity

Fix one more case of a possibly swallowed exception (#455)

Maybe spotbugs will add a rule for this in the future
Dieser Commit ist enthalten in:
A248 2021-04-02 01:45:58 -04:00 committet von GitHub
Ursprung be21ac5a30
Commit 7ba2318506
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -309,7 +309,11 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
mcConnection.setSessionHandler(new InitialConnectSessionHandler(player)); mcConnection.setSessionHandler(new InitialConnectSessionHandler(player));
server.getEventManager().fire(new PostLoginEvent(player)) server.getEventManager().fire(new PostLoginEvent(player))
.thenRun(() -> connectToInitialServer(player)); .thenCompose((ignored) -> connectToInitialServer(player))
.exceptionally((ex) -> {
logger.error("Exception while connecting {} to initial server", player, ex);
return null;
});
} }
}, mcConnection.eventLoop()) }, mcConnection.eventLoop())
.exceptionally((ex) -> { .exceptionally((ex) -> {
@ -318,12 +322,12 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
}); });
} }
private void connectToInitialServer(ConnectedPlayer player) { private CompletableFuture<Void> connectToInitialServer(ConnectedPlayer player) {
Optional<RegisteredServer> initialFromConfig = player.getNextServerToTry(); Optional<RegisteredServer> initialFromConfig = player.getNextServerToTry();
PlayerChooseInitialServerEvent event = new PlayerChooseInitialServerEvent(player, PlayerChooseInitialServerEvent event = new PlayerChooseInitialServerEvent(player,
initialFromConfig.orElse(null)); initialFromConfig.orElse(null));
server.getEventManager().fire(event) return server.getEventManager().fire(event)
.thenRunAsync(() -> { .thenRunAsync(() -> {
Optional<RegisteredServer> toTry = event.getInitialServer(); Optional<RegisteredServer> toTry = event.getInitialServer();
if (!toTry.isPresent()) { if (!toTry.isPresent()) {
@ -332,11 +336,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
return; return;
} }
player.createConnectionRequest(toTry.get()).fireAndForget(); player.createConnectionRequest(toTry.get()).fireAndForget();
}, mcConnection.eventLoop()) }, mcConnection.eventLoop());
.exceptionally((ex) -> {
logger.error("Exception while connecting {} to initial server", player, ex);
return null;
});
} }
@Override @Override