2929import org .openworkflow .sdk .impl .WorkflowException ;
3030import org .openworkflow .sdk .impl .WorkflowModel ;
3131import org .openworkflow .sdk .impl .WorkflowModelFactory ;
32+ import org .openworkflow .sdk .impl .WorkflowUtils ;
3233import org .openworkflow .sdk .impl .executors .ProcessResult ;
3334import org .slf4j .Logger ;
3435import 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 ) {
0 commit comments