Program: 79673
Project: 79673
Buggy source:
@Override public Integer create() throws Exception {
  try {
    session=acquire(newSessionAction());
    shell=session.startShell();
    if (out != null) {
      InputStream outstream=shell.getInputStream();
      outgobbler=new StreamGobbler(outstream,out,(Logger)null);
      outgobbler.start();
    }
    if (err != null) {
      InputStream errstream=shell.getErrorStream();
      errgobbler=new StreamGobbler(errstream,err,(Logger)null);
      errgobbler.start();
    }
    OutputStream output=shell.getOutputStream();
    for (    CharSequence cmd : commands) {
      try {
        output.write(Strings.toUTF8ByteArray(cmd + "String_Node_Str"));
        output.flush();
      }
 catch (      ConnectionException e) {
        if (!shell.isOpen()) {
          if (LOG.isDebugEnabled())           LOG.debug("String_Node_Str",SshjTool.this.toString(),commands);
          break;
        }
 else {
          throw e;
        }
      }
    }
    shell.sendEOF();
    output.close();
    try {
      int timeout=sshClientConnection.getSessionTimeout();
      long timeoutEnd=System.currentTimeMillis() + timeout;
      Exception last=null;
      do {
        if (!shell.isOpen() && ((SessionChannel)session).getExitStatus() != null)         break;
        boolean endBecauseReturned=(!shell.isOpen() || ((SessionChannel)session).getExitStatus() != null);
        try {
          shell.join(1000,TimeUnit.MILLISECONDS);
        }
 catch (        ConnectionException e) {
          last=e;
        }
        if (endBecauseReturned)         break;
      }
 while (timeout <= 0 || System.currentTimeMillis() < timeoutEnd);
      if (shell.isOpen() && ((SessionChannel)session).getExitStatus() == null) {
        LOG.debug("String_Node_Str",sshClientConnection.getSessionTimeout(),this);
        throw last;
      }
      return ((SessionChannel)session).getExitStatus();
    }
  finally {
      try {
        shell.close();
      }
 catch (      Exception e) {
        LOG.debug("String_Node_Str" + e);
      }
      try {
        if (outgobbler != null)         outgobbler.join();
        if (errgobbler != null)         errgobbler.join();
      }
 catch (      InterruptedException e) {
        LOG.warn("String_Node_Str" + commands,e);
        Thread.currentThread().interrupt();
      }
    }
  }
  finally {
    clear();
  }
}

Fixed version (ground truth):
@Override public Integer create() throws Exception {
  try {
    session=acquire(newSessionAction());
    shell=session.startShell();
    if (out != null) {
      InputStream outstream=shell.getInputStream();
      outgobbler=new StreamGobbler(outstream,out,(Logger)null);
      outgobbler.start();
    }
    if (err != null) {
      InputStream errstream=shell.getErrorStream();
      errgobbler=new StreamGobbler(errstream,err,(Logger)null);
      errgobbler.start();
    }
    OutputStream output=shell.getOutputStream();
    for (    CharSequence cmd : commands) {
      try {
        output.write(Strings.toUTF8ByteArray(cmd + "String_Node_Str"));
        output.flush();
      }
 catch (      ConnectionException e) {
        if (!shell.isOpen()) {
          if (LOG.isDebugEnabled())           LOG.debug("String_Node_Str",SshjTool.this.toString(),commands);
          break;
        }
 else {
          throw e;
        }
      }
    }
    shell.sendEOF();
    closeWhispering(output,this);
    try {
      int timeout=sshClientConnection.getSessionTimeout();
      long timeoutEnd=System.currentTimeMillis() + timeout;
      Exception last=null;
      do {
        if (!shell.isOpen() && ((SessionChannel)session).getExitStatus() != null)         break;
        boolean endBecauseReturned=(!shell.isOpen() || ((SessionChannel)session).getExitStatus() != null);
        try {
          shell.join(1000,TimeUnit.MILLISECONDS);
        }
 catch (        ConnectionException e) {
          last=e;
        }
        if (endBecauseReturned)         break;
      }
 while (timeout <= 0 || System.currentTimeMillis() < timeoutEnd);
      if (shell.isOpen() && ((SessionChannel)session).getExitStatus() == null) {
        LOG.debug("String_Node_Str",sshClientConnection.getSessionTimeout(),this);
        throw last;
      }
      return ((SessionChannel)session).getExitStatus();
    }
  finally {
      closeWhispering(shell,this);
      shell=null;
      try {
        if (outgobbler != null)         outgobbler.join();
        if (errgobbler != null)         errgobbler.join();
      }
 catch (      InterruptedException e) {
        LOG.warn("String_Node_Str" + commands,e);
        Thread.currentThread().interrupt();
      }
    }
  }
  finally {
    clear();
  }
}