Program: 79648
Project: 79648
Buggy source:
/** 
 * executes the single given command (words) with given environmnet (inherited if null) and cwd (. if null), feeding it the given input stream (if not null). logs I/O at debug (if not null). throws exception if return code non-zero, otherwise returns lines from stdout. <p> flags:  timeout (Duration), 0 for forever; default 60 seconds
 */
public static String[] exec(Map flags,final String[] cmd,String[] envp,File dir,String input,final Logger log,final Object context){
  Closer closer=Closer.create();
  try {
    log.debug("String_Node_Str" + context + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str"));
    final Process proc=Runtime.getRuntime().exec(cmd,envp,dir);
    ByteArrayOutputStream stdoutB=new ByteArrayOutputStream();
    ByteArrayOutputStream stderrB=new ByteArrayOutputStream();
    PrintStream stdoutP=new GroovyPrintStream(stdoutB);
    PrintStream stderrP=new GroovyPrintStream(stderrB);
    @SuppressWarnings("String_Node_Str") StreamGobbler stdoutG=new StreamGobbler(proc.getInputStream(),stdoutP,log).setLogPrefix("String_Node_Str" + context + "String_Node_Str");
    stdoutG.start();
    closer.register(stdoutG);
    @SuppressWarnings("String_Node_Str") StreamGobbler stderrG=new StreamGobbler(proc.getErrorStream(),stderrP,log).setLogPrefix("String_Node_Str" + context + "String_Node_Str");
    stderrG.start();
    closer.register(stderrG);
    if (input != null && input.length() > 0) {
      proc.getOutputStream().write(input.getBytes());
      proc.getOutputStream().flush();
    }
    long timeout2=TIMEOUT;
    Object tf=flags.get("String_Node_Str");
    if (tf instanceof Number)     timeout2=((Number)tf).longValue();
 else     if (tf instanceof Duration)     timeout2=((Duration)tf).toMilliseconds();
 else     if (tf instanceof TimeDuration)     timeout2=((TimeDuration)tf).toMilliseconds();
    if (tf != null)     timeout2=(Long)tf;
    final long timeout=timeout2;
    final AtomicBoolean ended=new AtomicBoolean(false);
    final AtomicBoolean killed=new AtomicBoolean(false);
    Thread t=new Thread(new Runnable(){
      public void run(){
        try {
          if (timeout > 0) {
            Thread.sleep(timeout);
            if (!ended.get()) {
              log.debug("String_Node_Str" + context + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str"));
              proc.destroy();
              killed.set(true);
            }
          }
        }
 catch (        Exception e) {
        }
      }
    }
);
    if (TIMEOUT > 0)     t.start();
    int exitCode=proc.waitFor();
    ended.set(true);
    if (TIMEOUT > 0)     t.interrupt();
    stdoutG.blockUntilFinished();
    stderrG.blockUntilFinished();
    if (exitCode != 0 || killed.get()) {
      String message=killed.get() ? "String_Node_Str" : "String_Node_Str" + exitCode;
      log.debug("String_Node_Str" + context + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str")+ "String_Node_Str"+ message);
      String e="String_Node_Str" + message + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str");
      log.warn(e + "String_Node_Str" + stdoutB+ (stderrB.size() > 0 ? "String_Node_Str" + stderrB : "String_Node_Str"));
      throw new IllegalStateException(e + "String_Node_Str");
    }
    log.debug("String_Node_Str" + context + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str")+ "String_Node_Str");
    return stdoutB.toString().split("String_Node_Str");
  }
 catch (  Exception e) {
    throw Exceptions.propagate(e);
  }
 finally {
    Streams.closeQuietly(closer);
  }
}

Fixed version (ground truth):
/** 
 * Executes the given command. <p> Uses the given environmnet (inherited if null) and cwd (  {@literal .} if null),feeding it the given input stream (if not null) and logging I/O at debug (if not null). <p> flags:  timeout (Duration), 0 for forever; default 60 seconds
 * @throws IllegalStateException if return code non-zero
 * @return lines from stdout.
 */
public static String[] exec(Map flags,final String[] cmd,String[] envp,File dir,String input,final Logger log,final Object context){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str",context,Strings.join(cmd,"String_Node_Str"));
  }
  Closer closer=Closer.create();
  try {
    final Process proc=Runtime.getRuntime().exec(cmd,envp,dir);
    ByteArrayOutputStream stdoutB=new ByteArrayOutputStream();
    ByteArrayOutputStream stderrB=new ByteArrayOutputStream();
    PrintStream stdoutP=new GroovyPrintStream(stdoutB);
    PrintStream stderrP=new GroovyPrintStream(stderrB);
    @SuppressWarnings("String_Node_Str") StreamGobbler stdoutG=new StreamGobbler(proc.getInputStream(),stdoutP,log).setLogPrefix("String_Node_Str" + context + "String_Node_Str");
    stdoutG.start();
    closer.register(stdoutG);
    @SuppressWarnings("String_Node_Str") StreamGobbler stderrG=new StreamGobbler(proc.getErrorStream(),stderrP,log).setLogPrefix("String_Node_Str" + context + "String_Node_Str");
    stderrG.start();
    closer.register(stderrG);
    if (input != null && input.length() > 0) {
      proc.getOutputStream().write(input.getBytes());
      proc.getOutputStream().flush();
    }
    final long timeout=getTimeoutMs(flags);
    final AtomicBoolean ended=new AtomicBoolean(false);
    final AtomicBoolean killed=new AtomicBoolean(false);
    Thread timeoutThread=new Thread(new Runnable(){
      public void run(){
        if (timeout <= 0)         return;
        try {
          Thread.sleep(timeout);
          if (!ended.get()) {
            if (log.isDebugEnabled()) {
              log.debug("String_Node_Str" + context + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str"));
            }
            proc.destroy();
            killed.set(true);
          }
        }
 catch (        Exception e) {
        }
      }
    }
);
    if (timeout > 0)     timeoutThread.start();
    int exitCode=proc.waitFor();
    ended.set(true);
    if (timeout > 0)     timeoutThread.interrupt();
    stdoutG.blockUntilFinished();
    stderrG.blockUntilFinished();
    if (exitCode != 0 || killed.get()) {
      String message=killed.get() ? "String_Node_Str" : "String_Node_Str" + exitCode;
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + context + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str")+ "String_Node_Str"+ message);
      }
      String e="String_Node_Str" + message + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str");
      log.warn(e + "String_Node_Str" + stdoutB+ (stderrB.size() > 0 ? "String_Node_Str" + stderrB : "String_Node_Str"));
      throw new IllegalStateException(e + "String_Node_Str");
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + context + "String_Node_Str"+ Strings.join(cmd,"String_Node_Str")+ "String_Node_Str");
    }
    return stdoutB.toString().split("String_Node_Str");
  }
 catch (  IOException e) {
    throw Exceptions.propagate(e);
  }
catch (  InterruptedException e) {
    throw Exceptions.propagate(e);
  }
 finally {
    Streams.closeQuietly(closer);
  }
}