diff --git a/plugin-script/src/main/java/io/kestra/plugin/scripts/jvm/FileTransform.java b/plugin-script/src/main/java/io/kestra/plugin/scripts/jvm/FileTransform.java index 8c434b8..590bf4e 100644 --- a/plugin-script/src/main/java/io/kestra/plugin/scripts/jvm/FileTransform.java +++ b/plugin-script/src/main/java/io/kestra/plugin/scripts/jvm/FileTransform.java @@ -74,7 +74,7 @@ protected FileTransform.Output run(RunContext runContext, String engineName) thr ); try ( - OutputStream output = new FileOutputStream(tempFile); + var output = new BufferedWriter(new FileWriter(tempFile), FileSerde.BUFFER_SIZE) ) { if (from.startsWith("kestra://")) { try (BufferedReader inputStream = new BufferedReader(new InputStreamReader(runContext.storage().getFile(URI.create(from))))) { @@ -117,7 +117,7 @@ protected void finalize( RunContext runContext, Flux flowable, ScriptEngineService.CompiledScript scripts, - OutputStream output + Writer output ) throws IOException, ScriptException { Flux sequential; @@ -132,9 +132,7 @@ protected void finalize( .flatMap(this.convert(scripts)); } - Mono count = sequential - .doOnNext(throwConsumer(row -> FileSerde.write(output, row))) - .count(); + Mono count = FileSerde.writeAll(output, sequential); // metrics & finalize Long lineCount = count.block();