diff --git a/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java b/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java index 91ff0627..3405d08e 100644 --- a/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java +++ b/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java @@ -31,7 +31,6 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; import java.util.concurrent.Executor; public class DependencyLoader { @@ -99,20 +98,8 @@ public class DependencyLoader { } private CompletableFuture download(ClasspathAppender appender) { - CompletableFuture future = new CompletableFuture<>(); - executor.execute(() -> { - try { - dependencyManager.downloadAll(executor, REPOSITORIES).join(); - dependencyManager.relocateAll(executor).join(); - dependencyManager.loadAll(executor, appender).join(); - - future.complete(null); - } catch (CompletionException e) { - future.completeExceptionally(e.getCause()); - } catch (Throwable t) { - future.completeExceptionally(t); - } - }); - return future; + return dependencyManager.downloadAll(executor, REPOSITORIES) + .thenCompose(v -> dependencyManager.relocateAll(executor)) + .thenCompose(v -> dependencyManager.loadAll(executor, appender)); } } diff --git a/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java b/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java index 2d13e99a..ae07a1d8 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java @@ -46,7 +46,7 @@ public class StandardScheduler implements Scheduler { Math.max(4, Runtime.getRuntime().availableProcessors() - 2), /* Timeout */ 60, TimeUnit.SECONDS, - new SynchronousQueue<>(), + new LinkedBlockingQueue<>(), new CountingThreadFactory(Scheduler.THREAD_NAME_PREFIX + "Executor #%s") ), new ScheduledThreadPoolExecutor(