Flush stdout and stderr before shutdown in scripts

Although a test is present, it doesn't check the behavior because it seems that
in the test environment both streams are necessarily flushed

 #KT-9546 Fixed
This commit is contained in:
Alexander Udalov
2016-03-29 13:43:16 +03:00
parent be4b432778
commit f31dca32a4
4 changed files with 19 additions and 1 deletions
@@ -238,7 +238,14 @@ object KotlinToJVMBytecodeCompiler {
val scriptConstructor = getScriptConstructor(scriptClass)
try {
scriptConstructor.newInstance(*arrayOf<Any>(scriptArgs.toTypedArray()))
try {
scriptConstructor.newInstance(*arrayOf<Any>(scriptArgs.toTypedArray()))
}
finally {
// NB: these lines are required (see KT-9546) but aren't covered by tests
System.out.flush()
System.err.flush()
}
}
catch (e: Throwable) {
reportExceptionFromScript(e)