fix exception not being passed through future

This commit is contained in:
ajgeiss0702
2021-12-11 10:43:53 -07:00
parent 443613d412
commit bce37cb278
2 changed files with 7 additions and 4 deletions
@@ -37,8 +37,10 @@ public class BungeeServer implements AdaptedServer {
CompletableFuture<AdaptedServerPing> future = new CompletableFuture<>();
handle.ping((pp, error) -> {
if(error != null) {
future.complete(null);
future.completeExceptionally(error);
return;
}
future.complete(new BungeeServerPing(pp));
});
return future;
@@ -36,11 +36,12 @@ public class VelocityServer implements AdaptedServer {
CompletableFuture<AdaptedServerPing> future = new CompletableFuture<>();
CompletableFuture<ServerPing> serverPing = handle.ping();
serverPing.thenRunAsync(() -> {
AdaptedServerPing aPing = null;
AdaptedServerPing aPing;
try {
aPing = new VelocityServerPing(serverPing.get());
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
} catch (Throwable e) {
future.completeExceptionally(e);
return;
}
future.complete(aPing);
});