diff --git a/test/org/rascalmpl/test/rpc/IValueOverJsonTests.java b/test/org/rascalmpl/test/rpc/IValueOverJsonTests.java index 115522aa92a..417dadbe87d 100644 --- a/test/org/rascalmpl/test/rpc/IValueOverJsonTests.java +++ b/test/org/rascalmpl/test/rpc/IValueOverJsonTests.java @@ -13,6 +13,7 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -72,6 +73,7 @@ public class IValueOverJsonTests { private JsonRpcTestInterface testServer; private final PipedInputStream is0, is1; private final PipedOutputStream os0, os1; + private final ExecutorService exec = Executors.newCachedThreadPool(); @Parameters(name="{0}") public static Iterable modesAndConfig() { @@ -92,7 +94,7 @@ public IValueOverJsonTests(ComplexTypeMode complexTypeMode, Consumer gsonConfig) { Launcher clientLauncher = new Launcher.Builder() - .setRemoteInterface(JsonRpcTestInterface.class) .setLocalService(this) + .setRemoteInterface(JsonRpcTestInterface.class) .setInput(is) .setOutput(os) .configureGson(gsonConfig) - .setExecutorService(Executors.newCachedThreadPool()) + .setExceptionHandler(e -> { + System.err.println(e); + return new ResponseError(ResponseErrorCode.InternalError, e.getMessage(), e); + }) + .setExecutorService(exec) .create(); clientLauncher.startListening(); @@ -135,11 +142,13 @@ static class TestThread extends Thread { private final InputStream is; private final OutputStream os; private final Consumer gsonConfig; + private final ExecutorService exec; - public TestThread(InputStream is, OutputStream os, Consumer gsonConfig) { + public TestThread(InputStream is, OutputStream os, Consumer gsonConfig, ExecutorService exec) { this.is = is; this.os = os; this.gsonConfig = gsonConfig; + this.exec = exec; this.setDaemon(true); } @@ -155,13 +164,14 @@ public void run() { System.err.println(e); return new ResponseError(ResponseErrorCode.InternalError, e.getMessage(), e); }) + .setExecutorService(exec) .create(); serverLauncher.startListening(); } } - private static Set asJsonObjectOrNotSupported = new HashSet<>(Arrays.asList(ComplexTypeMode.ENCODE_AS_JSON_OBJECT, ComplexTypeMode.NOT_SUPPORTED)); + private static final Set asJsonObjectOrNotSupported = new HashSet<>(Arrays.asList(ComplexTypeMode.ENCODE_AS_JSON_OBJECT, ComplexTypeMode.NOT_SUPPORTED)); private void runTestForPrimitiveType(String type, Supplier supplier, Function> function) { expectSuccessful(type, supplier, function);