Skip to content

Commit cd5e408

Browse files
committed
[Fix #1774] Discaring output and error recollection for await false
Signed-off-by: Francisco Javier Tirado Sarti <ftirados@ibm.com>
1 parent 69cc5a8 commit cd5e408

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎impl/core/src/main/java/org/openworkflow/sdk/impl/executors/RunShellExecutor.java‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ public CompletableFuture<WorkflowModel> apply(
8080
CompletableFuture.supplyAsync(
8181
() ->
8282
ScriptUtils.buildResultFromProcess(
83-
builder,
84-
returnType.orElse(ProcessReturnType.NONE),
85-
stdin,
86-
workflowContext,
87-
taskContext,
88-
model),
83+
builder, returnType.orElse(null), stdin, workflowContext, taskContext, model),
8984
workflowContext.definition().application().executorService());
9085
return returnType.isPresent() ? future : CompletableFuture.completedFuture(model);
9186
}

‎impl/core/src/main/java/org/openworkflow/sdk/impl/scripts/ScriptUtils.java‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openworkflow.sdk.impl.WorkflowException;
3030
import org.openworkflow.sdk.impl.WorkflowModel;
3131
import org.openworkflow.sdk.impl.WorkflowModelFactory;
32+
import org.openworkflow.sdk.impl.WorkflowUtils;
3233
import org.openworkflow.sdk.impl.executors.ProcessResult;
3334
import org.slf4j.Logger;
3435
import org.slf4j.LoggerFactory;
@@ -46,7 +47,10 @@ public static WorkflowModel modelFromOutput(
4647
if (code != 0) {
4748
logger.warn("Process call failed with code {}", code);
4849
if (logger.isDebugEnabled()) {
49-
logger.debug(streamSuppliers.errorStream().get());
50+
String str = streamSuppliers.errorStream().get();
51+
if (WorkflowUtils.isValid(str)) {
52+
logger.debug(str);
53+
}
5054
}
5155
}
5256
return switch (returnType) {
@@ -69,13 +73,15 @@ public static void addEnviromment(ProcessBuilder builder, Map<String, Object> en
6973
}
7074

7175
private static boolean keepOut(ProcessReturnType type, boolean dumpOutput) {
72-
return dumpOutput || type == ProcessReturnType.ALL || type == ProcessReturnType.STDOUT;
76+
return type != null
77+
&& (dumpOutput || type == ProcessReturnType.ALL || type == ProcessReturnType.STDOUT);
7378
}
7479

7580
private static boolean keepError(ProcessReturnType type) {
76-
return logger.isDebugEnabled()
77-
|| type == ProcessReturnType.ALL
78-
|| type == ProcessReturnType.STDERR;
81+
return type != null
82+
&& (logger.isDebugEnabled()
83+
|| type == ProcessReturnType.ALL
84+
|| type == ProcessReturnType.STDERR);
7985
}
8086

8187
public static WorkflowModel buildResultFromProcess(
@@ -101,7 +107,10 @@ public static WorkflowModel buildResultFromProcess(
101107
addStdin(process, stdin, taskContext);
102108
int code = process.waitFor();
103109
if (dumpOutput) {
104-
System.out.println(suppliers.outputStream().get());
110+
String str = suppliers.outputStream().get();
111+
if (WorkflowUtils.isValid(str)) {
112+
System.out.println(str);
113+
}
105114
}
106115
return modelFromOutput(code, suppliers, type, app.modelFactory(), model);
107116
} catch (InterruptedException e) {

‎impl/core/src/main/java/org/openworkflow/sdk/impl/scripts/StreamSuppliers.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void close() {
104104
private static class DiscardStreamSupplier implements StreamSupplier {
105105
@Override
106106
public String get() {
107-
throw new UnsupportedOperationException("Stream information was discarded");
107+
return "";
108108
}
109109

110110
@Override

0 commit comments

Comments
 (0)