From ac25fa7c1f62357242b82f18a248e0dbac16262d Mon Sep 17 00:00:00 2001 From: Sebastian Baunsgaard Date: Tue, 8 Aug 2023 20:47:28 +0200 Subject: [PATCH] Fix it --- .../sysds/runtime/util/DoubleBufferingOutputStream.java | 6 +++++- .../sysds/test/functions/paramserv/ParamservSyntaxTest.java | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/sysds/runtime/util/DoubleBufferingOutputStream.java b/src/main/java/org/apache/sysds/runtime/util/DoubleBufferingOutputStream.java index 122b1db6f58..16504e64eed 100644 --- a/src/main/java/org/apache/sysds/runtime/util/DoubleBufferingOutputStream.java +++ b/src/main/java/org/apache/sysds/runtime/util/DoubleBufferingOutputStream.java @@ -23,11 +23,14 @@ import java.io.IOException; import java.io.OutputStream; import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.commons.lang3.concurrent.ConcurrentUtils; public class DoubleBufferingOutputStream extends FilterOutputStream { + protected ExecutorService _pool = Executors.newSingleThreadExecutor(); protected Future[] _locks; protected byte[][] _buff; private int _pos; @@ -66,7 +69,7 @@ public void write(byte[] b, int off, int len) System.arraycopy(b, off, _buff[_pos], 0, len); //submit write request - _locks[_pos] = CommonThreadPool.getDynamicPool().submit(new WriteTask(_buff[_pos], len)); + _locks[_pos] = _pool.submit(new WriteTask(_buff[_pos], len)); _pos = (_pos+1) % _buff.length; } } @@ -100,6 +103,7 @@ public void flush() throws IOException { @Override public void close() throws IOException { + _pool.shutdown(); super.close(); } diff --git a/src/test/java/org/apache/sysds/test/functions/paramserv/ParamservSyntaxTest.java b/src/test/java/org/apache/sysds/test/functions/paramserv/ParamservSyntaxTest.java index f3804066e3c..7d4b5f4b257 100644 --- a/src/test/java/org/apache/sysds/test/functions/paramserv/ParamservSyntaxTest.java +++ b/src/test/java/org/apache/sysds/test/functions/paramserv/ParamservSyntaxTest.java @@ -93,9 +93,11 @@ public void testParamservMinimumVersion() { private void runDMLTest(String testname, boolean exceptionExpected, Class exceptionClass, String errmsg) { TestConfiguration config = getTestConfiguration(testname); + setOutputBuffering(true); loadTestConfiguration(config); programArgs = new String[] { "-explain" }; fullDMLScriptName = HOME + testname + ".dml"; runTest(true, exceptionExpected, exceptionClass, errmsg, -1); + setOutputBuffering(false); } }