Skip to content

Commit 1364e3c

Browse files
committed
Let ScriptModules flush their output after their done
This is required to make sure that the errors that were printed to the provided error writer (e.g. in the error panel of the script editor) are actually shown. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent a29c37d commit 1364e3c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/org/scijava/script/ScriptModule.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
package org.scijava.script;
3333

3434
import java.io.FileReader;
35+
import java.io.IOException;
3536
import java.io.PrintWriter;
3637
import java.io.Reader;
3738
import java.io.Writer;
@@ -191,6 +192,20 @@ public void run() {
191192
final Object typed = ConversionUtils.convert(decoded, item.getType());
192193
setOutput(name, typed);
193194
}
195+
196+
if (output != null) try {
197+
output.flush();
198+
} catch (IOException e) {
199+
if (error == null) {
200+
log.error(e);
201+
} else {
202+
e.printStackTrace(errorPrinter);
203+
}
204+
}
205+
206+
if (errorPrinter != null) {
207+
errorPrinter.flush();
208+
}
194209
}
195210

196211
// -- Contextual methods --

0 commit comments

Comments
 (0)