Skip to content

Commit

Permalink
fix(ssh): missing Thread.join() on the log threads (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu committed Apr 3, 2023
1 parent f57925a commit 886ba21
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/io/kestra/plugin/fs/ssh/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ public VoidOutput run(RunContext runContext) throws Exception {
channel.setCommand(String.join("\n", renderedCommands));
channel.setOutputStream(new BufferedOutputStream(outStream), true);
channel.setErrStream(new BufferedOutputStream(errStream), true);
threadLogSupplier(runContext).call(inStream, false);
threadLogSupplier(runContext).call(inErrStream, true);
var stdOut = threadLogSupplier(runContext).call(inStream, false);
var stdErr = threadLogSupplier(runContext).call(inErrStream, true);

channel.connect();
while (channel.isConnected()) {
Thread.sleep(SLEEP_DELAY_MS);
}

stdOut.join();
stdErr.join();

if(channel.getExitStatus() != 0) {
throw new Exception("SSH command fails with exit status " + channel.getExitStatus());
}
Expand Down

0 comments on commit 886ba21

Please sign in to comment.