From ae752c6f630ba844736074e84e97722a450d29f8 Mon Sep 17 00:00:00 2001 From: tom lee Date: Sat, 12 Feb 2022 22:47:49 +0800 Subject: [PATCH] Fixed it so it works with Java 8 --- .../lod/core/util/DummyRunExecutorService.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/util/DummyRunExecutorService.java b/src/main/java/com/seibel/lod/core/util/DummyRunExecutorService.java index 62e0aa8f7..93002b661 100644 --- a/src/main/java/com/seibel/lod/core/util/DummyRunExecutorService.java +++ b/src/main/java/com/seibel/lod/core/util/DummyRunExecutorService.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -29,7 +30,7 @@ public class DummyRunExecutorService implements ExecutorService { public List shutdownNow() { shutdownCalled = true; - return List.of(); + return new ArrayList(); } @Override @@ -57,10 +58,8 @@ public class DummyRunExecutorService implements ExecutorService { try { return CompletableFuture.completedFuture(task.call()); - } - catch (Throwable e) - { - return CompletableFuture.failedFuture(e); + } catch (Throwable e) { + return CompletableFuture.supplyAsync( () -> {throw new CompletionException(e);}, Runnable::run); } } @@ -74,7 +73,7 @@ public class DummyRunExecutorService implements ExecutorService { } catch (Throwable e) { - return CompletableFuture.failedFuture(e); + return CompletableFuture.supplyAsync( () -> {throw new CompletionException(e);}, Runnable::run); } } @@ -88,7 +87,7 @@ public class DummyRunExecutorService implements ExecutorService { } catch (Throwable e) { - return CompletableFuture.failedFuture(e); + return CompletableFuture.supplyAsync( () -> {throw new CompletionException(e);}, Runnable::run); } }