fix exception not being passed through future
This commit is contained in:
+3
-1
@@ -37,8 +37,10 @@ public class BungeeServer implements AdaptedServer {
|
|||||||
CompletableFuture<AdaptedServerPing> future = new CompletableFuture<>();
|
CompletableFuture<AdaptedServerPing> future = new CompletableFuture<>();
|
||||||
handle.ping((pp, error) -> {
|
handle.ping((pp, error) -> {
|
||||||
if(error != null) {
|
if(error != null) {
|
||||||
future.complete(null);
|
future.completeExceptionally(error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
future.complete(new BungeeServerPing(pp));
|
future.complete(new BungeeServerPing(pp));
|
||||||
});
|
});
|
||||||
return future;
|
return future;
|
||||||
|
|||||||
+4
-3
@@ -36,11 +36,12 @@ public class VelocityServer implements AdaptedServer {
|
|||||||
CompletableFuture<AdaptedServerPing> future = new CompletableFuture<>();
|
CompletableFuture<AdaptedServerPing> future = new CompletableFuture<>();
|
||||||
CompletableFuture<ServerPing> serverPing = handle.ping();
|
CompletableFuture<ServerPing> serverPing = handle.ping();
|
||||||
serverPing.thenRunAsync(() -> {
|
serverPing.thenRunAsync(() -> {
|
||||||
AdaptedServerPing aPing = null;
|
AdaptedServerPing aPing;
|
||||||
try {
|
try {
|
||||||
aPing = new VelocityServerPing(serverPing.get());
|
aPing = new VelocityServerPing(serverPing.get());
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
future.completeExceptionally(e);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
future.complete(aPing);
|
future.complete(aPing);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user