Program: 28330
Project: 28330
Buggy source:
private void copyToHostsInternal(File zipFile,ArrayList<String> binDirFiles) throws IOException, InterruptedException, CommandException {
  ByteArrayOutputStream outStream=new ByteArrayOutputStream();
  boolean prompt=promptPass;
  for (  String host : hosts) {
    sshLauncher.init(getRemoteUser(),host,getRemotePort(),sshpassword,getSshKeyFile(),sshkeypassphrase,logger);
    if (getSshKeyFile() != null && !sshLauncher.checkConnection()) {
      prompt=true;
    }
    if (prompt) {
      String sshpass=null;
      if (sshPasswords.containsKey(host))       sshpass=String.valueOf(sshPasswords.get(host));
 else       sshpass=getSSHPassword(host);
      sshLauncher.init(getRemoteUser(),host,getRemotePort(),sshpass,getSshKeyFile(),sshkeypassphrase,logger);
      prompt=false;
    }
    String sshInstallDir=getInstallDir().replace('\\','/');
    SFTPClient sftpClient=sshLauncher.getSFTPClient();
    SCPClient scpClient=sshLauncher.getSCPClient();
    try {
      if (!sftpClient.exists(sshInstallDir)) {
        sftpClient.mkdirs(sshInstallDir,0755);
      }
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",sshInstallDir,host));
      throw new IOException(ioe);
    }
    try {
      List<String> files=getListOfInstallFiles(sshInstallDir);
      deleteRemoteFiles(sftpClient,files,sshInstallDir,getForce());
    }
 catch (    IOException ex) {
      logger.finer("String_Node_Str");
      throw new IOException(ex);
    }
    String zip=zipFile.getCanonicalPath();
    try {
      logger.info("String_Node_Str" + zip + "String_Node_Str"+ zipFile.length()+ "String_Node_Str"+ "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
      scpClient.put(zipFile.getAbsolutePath(),FileUtils.quoteString(sshInstallDir));
      logger.finer("String_Node_Str" + zip + "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
    }
 catch (    IOException ex) {
      logger.info(Strings.get("String_Node_Str",zip,host));
      throw new IOException(ex);
    }
    try {
      logger.info("String_Node_Str" + getArchiveName() + "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
      String unzipCommand="String_Node_Str" + sshInstallDir + "String_Node_Str"+ getArchiveName();
      int status=sshLauncher.runCommand(unzipCommand,outStream);
      if (status != 0) {
        logger.info(Strings.get("String_Node_Str",host,outStream.toString()));
        throw new CommandException("String_Node_Str" + outStream.toString());
      }
      logger.finer("String_Node_Str" + getArchiveName() + "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",host,outStream.toString()));
      throw new IOException(ioe);
    }
    try {
      logger.info("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ getArchiveName());
      sftpClient.rm(sshInstallDir + "String_Node_Str" + getArchiveName());
      logger.finer("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ getArchiveName());
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",host,sshInstallDir));
      throw new IOException(ioe);
    }
    logger.info("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir);
    try {
      if (binDirFiles.isEmpty()) {
        searchAndFixBinDirectoryFiles(sshInstallDir,sftpClient);
      }
 else {
        for (        String binDirFile : binDirFiles) {
          sftpClient.chmod((sshInstallDir + "String_Node_Str" + binDirFile),0755);
        }
      }
      logger.finer("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir);
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",host,sshInstallDir));
      throw new IOException(ioe);
    }
    if (Constants.v4) {
      logger.info("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ SystemPropertyConstants.getComponentName()+ "String_Node_Str");
      try {
        sftpClient.chmod((sshInstallDir + "String_Node_Str" + SystemPropertyConstants.getComponentName()+ "String_Node_Str"),0755);
        logger.finer("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ SystemPropertyConstants.getComponentName()+ "String_Node_Str");
      }
 catch (      IOException ioe) {
        logger.info(Strings.get("String_Node_Str",host,sshInstallDir));
        throw new IOException(ioe);
      }
    }
    sftpClient.close();
  }
}

Fixed version (ground truth):
private void copyToHostsInternal(File zipFile,ArrayList<String> binDirFiles) throws IOException, InterruptedException, CommandException {
  ByteArrayOutputStream outStream=new ByteArrayOutputStream();
  boolean prompt=promptPass;
  for (  String host : hosts) {
    sshLauncher.init(getRemoteUser(),host,getRemotePort(),sshpassword,getSshKeyFile(),sshkeypassphrase,logger);
    if (getSshKeyFile() != null && !sshLauncher.checkConnection()) {
      prompt=true;
    }
    if (prompt) {
      String sshpass=null;
      if (sshPasswords.containsKey(host))       sshpass=String.valueOf(sshPasswords.get(host));
 else       sshpass=getSSHPassword(host);
      sshLauncher.init(getRemoteUser(),host,getRemotePort(),sshpass,getSshKeyFile(),sshkeypassphrase,logger);
      prompt=false;
    }
    String sshInstallDir=getInstallDir().replace('\\','/');
    SFTPClient sftpClient=sshLauncher.getSFTPClient();
    SCPClient scpClient=sshLauncher.getSCPClient();
    try {
      if (!sftpClient.exists(sshInstallDir)) {
        sftpClient.mkdirs(sshInstallDir,0755);
      }
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",sshInstallDir,host));
      throw new IOException(ioe);
    }
    try {
      List<String> files=getListOfInstallFiles(sshInstallDir);
      deleteRemoteFiles(sftpClient,files,sshInstallDir,getForce());
    }
 catch (    IOException ex) {
      logger.finer("String_Node_Str");
      throw new IOException(ex);
    }
    String zip=zipFile.getCanonicalPath();
    try {
      logger.info("String_Node_Str" + zip + "String_Node_Str"+ zipFile.length()+ "String_Node_Str"+ "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
      scpClient.put(zipFile.getAbsolutePath(),FileUtils.quoteString(sshInstallDir));
      if (logger.isLoggable(Level.FINER))       logger.finer("String_Node_Str" + zip + "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
    }
 catch (    IOException ex) {
      logger.info(Strings.get("String_Node_Str",zip,host));
      throw new IOException(ex);
    }
    try {
      logger.info("String_Node_Str" + getArchiveName() + "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
      String unzipCommand="String_Node_Str" + sshInstallDir + "String_Node_Str"+ getArchiveName();
      int status=sshLauncher.runCommand(unzipCommand,outStream);
      if (status != 0) {
        logger.info(Strings.get("String_Node_Str",host,outStream.toString()));
        throw new CommandException("String_Node_Str" + outStream.toString());
      }
      if (logger.isLoggable(Level.FINER))       logger.finer("String_Node_Str" + getArchiveName() + "String_Node_Str"+ host+ "String_Node_Str"+ sshInstallDir);
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",host,outStream.toString()));
      throw new IOException(ioe);
    }
    try {
      logger.info("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ getArchiveName());
      sftpClient.rm(sshInstallDir + "String_Node_Str" + getArchiveName());
      if (logger.isLoggable(Level.FINER))       logger.finer("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ getArchiveName());
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",host,sshInstallDir));
      throw new IOException(ioe);
    }
    logger.info("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir);
    try {
      if (binDirFiles.isEmpty()) {
        searchAndFixBinDirectoryFiles(sshInstallDir,sftpClient);
      }
 else {
        for (        String binDirFile : binDirFiles) {
          sftpClient.chmod((sshInstallDir + "String_Node_Str" + binDirFile),0755);
        }
      }
      if (logger.isLoggable(Level.FINER))       logger.finer("String_Node_Str" + "String_Node_Str" + host + "String_Node_Str"+ sshInstallDir);
    }
 catch (    IOException ioe) {
      logger.info(Strings.get("String_Node_Str",host,sshInstallDir));
      throw new IOException(ioe);
    }
    if (Constants.v4) {
      logger.info("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ SystemPropertyConstants.getComponentName()+ "String_Node_Str");
      try {
        sftpClient.chmod((sshInstallDir + "String_Node_Str" + SystemPropertyConstants.getComponentName()+ "String_Node_Str"),0755);
        if (logger.isLoggable(Level.FINER))         logger.finer("String_Node_Str" + host + "String_Node_Str"+ sshInstallDir+ "String_Node_Str"+ SystemPropertyConstants.getComponentName()+ "String_Node_Str");
      }
 catch (      IOException ioe) {
        logger.info(Strings.get("String_Node_Str",host,sshInstallDir));
        throw new IOException(ioe);
      }
    }
    sftpClient.close();
  }
}