Program: 89605
Project: 89605
Buggy source:
/** 
 * Private constructor used by getInstance() static-method Tries to generate unique name on ftp-server.
 * @param localFile         File used to create new file on ftp-server.
 * @param useChecksums      If true, checksums will be used to checktransfers.
 * @param fileDeletable     If true, this file will be deleted after uploadto FTP.
 * @param multipleDownloads If true, the file will not be removed from FTPserver automatically after first download.
 * @param connectionParams  If not null, contains connection parameters to the FTP-server desired by the user 
 * @throws IOFailure        if MD5 checksum fails, or ftp fails
 * @throws ArgumentNotValid if the local file cannot be read.
 */
private FTPRemoteFile(File localFile,boolean useChecksums,boolean fileDeletable,boolean multipleDownloads,RemoteFileSettings connectionParams) throws IOFailure {
  super(localFile,useChecksums,fileDeletable,multipleDownloads);
  if (connectionParams != null) {
    this.ftpServerName=connectionParams.getServerName();
    this.ftpServerPort=connectionParams.getServerPort();
    this.ftpUserName=connectionParams.getUserName();
    this.ftpUserPassword=connectionParams.getUserPassword();
  }
 else {
    this.ftpServerName=Settings.get(CommonSettings.FTP_SERVER_NAME);
    this.ftpServerPort=Settings.getInt(CommonSettings.FTP_SERVER_PORT);
    this.ftpUserName=Settings.get(CommonSettings.FTP_USER_NAME);
    this.ftpUserPassword=Settings.get(CommonSettings.FTP_USER_PASSWORD);
  }
  if (filesize == 0) {
    try {
      if (useChecksums) {
        checksum=MD5.generateMD5onFile(file);
      }
 else {
        checksum=null;
      }
      ftpFileName="String_Node_Str";
    }
 catch (    IOException e) {
      String msg="String_Node_Str";
      if (e instanceof CopyStreamException) {
        CopyStreamException realException=(CopyStreamException)e;
        msg+="String_Node_Str" + realException.getIOException() + "String_Node_Str";
      }
      throw new IOFailure("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ msg,e);
    }
  }
 else {
    if (ftpServerName.equalsIgnoreCase("String_Node_Str")) {
      ftpServerName=SystemUtils.getLocalHostName();
      log.debug("String_Node_Str" + SystemUtils.getLocalHostName() + "String_Node_Str"+ ftpServerName);
    }
    final int aMagicNumber=100000;
    ftpFileName=file.getName() + "String_Node_Str" + new Random().nextInt(aMagicNumber)+ "String_Node_Str"+ new Date().getTime();
    InputStream in;
    try {
      in=new FileInputStream(localFile);
    }
 catch (    FileNotFoundException e) {
      final String message="String_Node_Str" + localFile + "String_Node_Str";
      log.debug(message,e);
      throw new IOFailure(message,e);
    }
    log.debug("String_Node_Str" + file.getName() + "String_Node_Str"+ ftpFileName+ "String_Node_Str"+ ftpServerName);
    try {
      logOn();
      if (useChecksums) {
        in=new DigestInputStream(in,MD5.getMessageDigestInstance());
      }
      boolean success=false;
      int tried=0;
      while (!success && tried < CommonSettings.FTP_RETRIES) {
        tried++;
        try {
          success=currentFTPClient.storeFile(ftpFileName,in);
          if (!success) {
            log.debug("String_Node_Str" + tried + "String_Node_Str"+ CommonSettings.FTP_RETRIES+ "String_Node_Str"+ getFtpErrorMessage());
          }
        }
 catch (        IOException e) {
          String message="String_Node_Str" + ftpFileName + "String_Node_Str"+ tried+ "String_Node_Str"+ CommonSettings.FTP_RETRIES;
          if (e instanceof CopyStreamException) {
            CopyStreamException realException=(CopyStreamException)e;
            message+="String_Node_Str" + realException.getIOException() + "String_Node_Str";
          }
          log.debug(message,e);
        }
      }
      if (!success) {
        final String msg="String_Node_Str" + localFile + "String_Node_Str"+ tried+ "String_Node_Str";
        log.warn(msg);
        throw new IOFailure(msg);
      }
      log.debug("String_Node_Str" + ftpFileName + "String_Node_Str");
      if (useChecksums) {
        checksum=MD5.toHex(((DigestInputStream)in).getMessageDigest().digest());
        log.debug("String_Node_Str" + ftpFileName + "String_Node_Str"+ checksum);
      }
 else {
        checksum=null;
      }
    }
  finally {
      try {
        if (in != null) {
          in.close();
        }
      }
 catch (      IOException e) {
        log.warn("String_Node_Str" + e);
      }
      logOut();
      log.debug("String_Node_Str");
    }
  }
  if (fileDeletable) {
    try {
      FileUtils.removeRecursively(localFile);
    }
 catch (    IOFailure e) {
      log.warn("String_Node_Str" + localFile,e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Private constructor used by getInstance() static-method Tries to generate unique name on ftp-server.
 * @param localFile         File used to create new file on ftp-server.
 * @param useChecksums      If true, checksums will be used to checktransfers.
 * @param fileDeletable     If true, this file will be deleted after uploadto FTP.
 * @param multipleDownloads If true, the file will not be removed from FTPserver automatically after first download.
 * @param connectionParams  If not null, contains connection parameters to the FTP-server desired by the user 
 * @throws IOFailure        if MD5 checksum fails, or ftp fails
 * @throws ArgumentNotValid if the local file cannot be read.
 */
private FTPRemoteFile(File localFile,boolean useChecksums,boolean fileDeletable,boolean multipleDownloads,RemoteFileSettings connectionParams) throws IOFailure {
  super(localFile,useChecksums,fileDeletable,multipleDownloads);
  if (connectionParams != null) {
    this.ftpServerName=connectionParams.getServerName();
    this.ftpServerPort=connectionParams.getServerPort();
    this.ftpUserName=connectionParams.getUserName();
    this.ftpUserPassword=connectionParams.getUserPassword();
  }
 else {
    this.ftpServerName=Settings.get(CommonSettings.FTP_SERVER_NAME);
    this.ftpServerPort=Settings.getInt(CommonSettings.FTP_SERVER_PORT);
    this.ftpUserName=Settings.get(CommonSettings.FTP_USER_NAME);
    this.ftpUserPassword=Settings.get(CommonSettings.FTP_USER_PASSWORD);
  }
  if (filesize == 0) {
    try {
      if (useChecksums) {
        checksum=MD5.generateMD5onFile(file);
      }
 else {
        checksum=null;
      }
      ftpFileName="String_Node_Str";
    }
 catch (    IOException e) {
      String msg="String_Node_Str";
      if (e instanceof CopyStreamException) {
        CopyStreamException realException=(CopyStreamException)e;
        msg+="String_Node_Str" + realException.getIOException() + "String_Node_Str";
      }
      throw new IOFailure("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ msg,e);
    }
  }
 else {
    if (ftpServerName.equalsIgnoreCase("String_Node_Str")) {
      ftpServerName=SystemUtils.getLocalHostName();
      log.debug("String_Node_Str" + SystemUtils.getLocalHostName() + "String_Node_Str"+ ftpServerName);
    }
    final int aMagicNumber=100000;
    ftpFileName=file.getName() + "String_Node_Str" + new Random().nextInt(aMagicNumber)+ "String_Node_Str"+ new Date().getTime();
    InputStream in;
    try {
      in=new FileInputStream(localFile);
    }
 catch (    FileNotFoundException e) {
      final String message="String_Node_Str" + localFile + "String_Node_Str";
      log.debug(message,e);
      throw new IOFailure(message,e);
    }
    log.debug("String_Node_Str" + file.getName() + "String_Node_Str"+ ftpFileName+ "String_Node_Str"+ ftpServerName);
    try {
      logOn();
      if (useChecksums) {
        in=new DigestInputStream(in,MD5.getMessageDigestInstance());
      }
      boolean success=false;
      int tried=0;
      while (!success && tried < FTP_RETRIES) {
        tried++;
        try {
          success=currentFTPClient.storeFile(ftpFileName,in);
          if (!success) {
            log.debug("String_Node_Str" + tried + "String_Node_Str"+ FTP_RETRIES+ "String_Node_Str"+ getFtpErrorMessage());
          }
        }
 catch (        IOException e) {
          String message="String_Node_Str" + ftpFileName + "String_Node_Str"+ tried+ "String_Node_Str"+ FTP_RETRIES;
          if (e instanceof CopyStreamException) {
            CopyStreamException realException=(CopyStreamException)e;
            message+="String_Node_Str" + realException.getIOException() + "String_Node_Str";
          }
          log.debug(message,e);
        }
      }
      if (!success) {
        final String msg="String_Node_Str" + localFile + "String_Node_Str"+ tried+ "String_Node_Str";
        log.warn(msg);
        throw new IOFailure(msg);
      }
      log.debug("String_Node_Str" + ftpFileName + "String_Node_Str");
      if (useChecksums) {
        checksum=MD5.toHex(((DigestInputStream)in).getMessageDigest().digest());
        log.debug("String_Node_Str" + ftpFileName + "String_Node_Str"+ checksum);
      }
 else {
        checksum=null;
      }
    }
  finally {
      try {
        if (in != null) {
          in.close();
        }
      }
 catch (      IOException e) {
        log.warn("String_Node_Str" + e);
      }
      logOut();
      log.debug("String_Node_Str");
    }
  }
  if (fileDeletable) {
    try {
      FileUtils.removeRecursively(localFile);
    }
 catch (    IOFailure e) {
      log.warn("String_Node_Str" + localFile,e);
    }
  }
}