Program: 29261
Project: 29261
Buggy source:
public File downloadGivenInstanceLogFile(ServiceLocator habitat,Server targetServer,Domain domain,Logger logger,String instanceName,String domainRoot,String logFileName,String instanceLogFileName) throws IOException {
  File instanceLogFile=null;
  SSHLauncher sshL=getSSHL(habitat);
  String sNode=targetServer.getNodeRef();
  Nodes nodes=domain.getNodes();
  Node node=nodes.getNode(sNode);
  if (node.getType().equals("String_Node_Str")) {
    sshL.init(node,logger);
    SFTPClient sftpClient=sshL.getSFTPClient();
    File logFileDirectoryOnServer=makingDirectory(domainRoot + File.separator + "String_Node_Str"+ File.separator+ instanceName);
    boolean noFileFound=true;
    String loggingDir=getLoggingDirectoryForNode(instanceLogFileName,node,sNode,instanceName);
    try {
      Vector instanceLogFileNames=sftpClient.ls(loggingDir);
      for (int i=0; i < instanceLogFileNames.size(); i++) {
        SFTPv3DirectoryEntry file=(SFTPv3DirectoryEntry)instanceLogFileNames.get(i);
        String fileName=file.filename;
        if (!file.attributes.isDirectory() && !fileName.equals("String_Node_Str") && !fileName.equals("String_Node_Str")&& fileName.contains("String_Node_Str")&& !fileName.contains("String_Node_Str")) {
          noFileFound=false;
          break;
        }
      }
    }
 catch (    Exception e) {
      noFileFound=true;
    }
    if (noFileFound) {
      loggingDir=getLoggingDirectoryForNodeWhenNoFilesFound(instanceLogFileName,node,sNode,instanceName);
    }
    String loggingFile=loggingDir + File.separator + logFileName;
    if (!sftpClient.exists(loggingFile)) {
      loggingFile=loggingDir + File.separator + "String_Node_Str";
    }
 else     if (!sftpClient.exists(loggingFile)) {
      loggingFile=instanceLogFileName;
    }
    long instanceLogFileSize=0;
    instanceLogFile=new File(logFileDirectoryOnServer.getAbsolutePath() + File.separator + loggingFile.substring(loggingFile.lastIndexOf(File.separator),loggingFile.length()));
    if (instanceLogFile.exists())     instanceLogFileSize=instanceLogFile.length();
    SFTPv3FileAttributes sftPv3FileAttributes=sftpClient._stat(loggingFile);
    long fileSizeOnNode=sftPv3FileAttributes.size;
    if (instanceLogFileSize != fileSizeOnNode) {
      BufferedInputStream in=null;
      FileOutputStream file=null;
      BufferedOutputStream out=null;
      InputStream inputStream=sftpClient.read(loggingFile);
      in=new BufferedInputStream(inputStream);
      file=new FileOutputStream(instanceLogFile);
      out=new BufferedOutputStream(file);
      int i;
      while ((i=in.read()) != -1) {
        out.write(i);
      }
      out.flush();
    }
    sftpClient.close();
  }
 else   if (node.getType().equals("String_Node_Str")) {
    File logFileDirectoryOnServer=makingDirectory(domainRoot + File.separator + "String_Node_Str"+ File.separator+ instanceName);
    String loggingDir=getLoggingDirectoryForNode(instanceLogFileName,node,sNode,instanceName);
    try {
      DcomInfo info=new DcomInfo(node);
      WindowsRemoteFileSystem wrfs=new WindowsRemoteFileSystem(info.getHost(),info.getUser(),info.getPassword());
      if (logFileName == null || logFileName.equals("String_Node_Str")) {
        logFileName="String_Node_Str";
      }
      WindowsRemoteFile wrf=new WindowsRemoteFile(wrfs,loggingDir + File.separator + logFileName);
      instanceLogFile=new File(logFileDirectoryOnServer + File.separator + logFileName);
      wrf.copyTo(instanceLogFile);
    }
 catch (    WindowsException ex) {
      throw new IOException("String_Node_Str");
    }
  }
  return instanceLogFile;
}

Fixed version (ground truth):
public File downloadGivenInstanceLogFile(ServiceLocator habitat,Server targetServer,Domain domain,Logger logger,String instanceName,String domainRoot,String logFileName,String instanceLogFileName) throws IOException {
  File instanceLogFile=null;
  SSHLauncher sshL=getSSHL(habitat);
  String sNode=targetServer.getNodeRef();
  Nodes nodes=domain.getNodes();
  Node node=nodes.getNode(sNode);
  if (node.getType().equals("String_Node_Str")) {
    sshL.init(node,logger);
    SFTPClient sftpClient=sshL.getSFTPClient();
    File logFileDirectoryOnServer=makingDirectory(domainRoot + File.separator + "String_Node_Str"+ File.separator+ instanceName);
    boolean noFileFound=true;
    String loggingDir=getLoggingDirectoryForNode(instanceLogFileName,node,sNode,instanceName);
    try {
      Vector instanceLogFileNames=sftpClient.ls(loggingDir);
      for (int i=0; i < instanceLogFileNames.size(); i++) {
        SFTPv3DirectoryEntry file=(SFTPv3DirectoryEntry)instanceLogFileNames.get(i);
        String fileName=file.filename;
        if (!file.attributes.isDirectory() && !fileName.equals("String_Node_Str") && !fileName.equals("String_Node_Str")&& fileName.contains("String_Node_Str")&& !fileName.contains("String_Node_Str")) {
          noFileFound=false;
          break;
        }
      }
    }
 catch (    Exception e) {
      noFileFound=true;
    }
    if (noFileFound) {
      loggingDir=getLoggingDirectoryForNodeWhenNoFilesFound(instanceLogFileName,node,sNode,instanceName);
    }
    String loggingFile=loggingDir + File.separator + logFileName;
    if (!sftpClient.exists(loggingFile)) {
      loggingFile=loggingDir + File.separator + "String_Node_Str";
    }
 else     if (!sftpClient.exists(loggingFile)) {
      loggingFile=instanceLogFileName;
    }
    long instanceLogFileSize=0;
    instanceLogFile=new File(logFileDirectoryOnServer.getAbsolutePath() + File.separator + loggingFile.substring(loggingFile.lastIndexOf(File.separator),loggingFile.length()));
    if (instanceLogFile.exists())     instanceLogFileSize=instanceLogFile.length();
    SFTPv3FileAttributes sftPv3FileAttributes=sftpClient._stat(loggingFile);
    long fileSizeOnNode=sftPv3FileAttributes.size;
    if (instanceLogFileSize != fileSizeOnNode) {
      BufferedInputStream in=null;
      FileOutputStream file=null;
      BufferedOutputStream out=null;
      try {
        InputStream inputStream=sftpClient.read(loggingFile);
        in=new BufferedInputStream(inputStream);
        file=new FileOutputStream(instanceLogFile);
        out=new BufferedOutputStream(file);
        int i;
        while ((i=in.read()) != -1) {
          out.write(i);
        }
        out.flush();
      }
  finally {
        if (out != null)         try {
          out.close();
        }
 catch (        IOException ex) {
        }
        if (in != null)         try {
          in.close();
        }
 catch (        IOException ex) {
        }
      }
    }
    sftpClient.close();
  }
 else   if (node.getType().equals("String_Node_Str")) {
    File logFileDirectoryOnServer=makingDirectory(domainRoot + File.separator + "String_Node_Str"+ File.separator+ instanceName);
    String loggingDir=getLoggingDirectoryForNode(instanceLogFileName,node,sNode,instanceName);
    try {
      DcomInfo info=new DcomInfo(node);
      WindowsRemoteFileSystem wrfs=new WindowsRemoteFileSystem(info.getHost(),info.getUser(),info.getPassword());
      if (logFileName == null || logFileName.equals("String_Node_Str")) {
        logFileName="String_Node_Str";
      }
      WindowsRemoteFile wrf=new WindowsRemoteFile(wrfs,loggingDir + File.separator + logFileName);
      instanceLogFile=new File(logFileDirectoryOnServer + File.separator + logFileName);
      wrf.copyTo(instanceLogFile);
    }
 catch (    WindowsException ex) {
      throw new IOException("String_Node_Str");
    }
  }
  return instanceLogFile;
}