Program: 89826
Project: 89826
Buggy source:
/** 
 * This method does the following: Retrieves the path to the jmxremote.access and jmxremote.password files. Moves these files, if they are different from standard. This has to be a force move (command 'move /Y'). Makes the jmxremote.access and jmxremote.password files readonly.
 * @return The commands for handling the jmxremote files.
 */
@Override protected String getJMXremoteFilesCommand(){
  String accessFilePath;
  String passwordFilePath;
  String[] options;
  options=settings.getLeafValues(Constants.SETTINGS_COMMON_JMX_ACCESSFILE);
  if (options == null || options.length < 0) {
    accessFilePath=Constants.JMX_ACCESS_FILE_PATH_DEFAULT;
  }
 else {
    accessFilePath=options[0];
    if (options.length > 1) {
      log.debug(Constants.MSG_WARN_TOO_MANY_JMXREMOTE_FILE_PATHS);
    }
  }
  options=settings.getLeafValues(Constants.SETTINGS_COMMON_JMX_PASSWORDFILE);
  if (options == null || options.length < 0) {
    passwordFilePath=Constants.JMX_PASSWORD_FILE_PATH_DEFAULT;
  }
 else {
    passwordFilePath=options[0];
    if (options.length > 1) {
      log.debug(Constants.MSG_WARN_TOO_MANY_JMXREMOTE_FILE_PATHS);
    }
  }
  accessFilePath=ScriptConstants.replaceWindowsDirSeparators(accessFilePath);
  passwordFilePath=ScriptConstants.replaceWindowsDirSeparators(passwordFilePath);
  StringBuilder res=new StringBuilder();
  res.append(ScriptConstants.ECHO_MAKE_PASSWORD_FILES);
  res.append(Constants.NEWLINE);
  if (!accessFilePath.equals(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_ACCESS_FILE_PATH_DEFAULT))) {
    res.append(ScriptConstants.SSH + Constants.SPACE);
    res.append(machineUserLogin());
    res.append(Constants.SPACE + Constants.QUOTE_MARK);
    res.append(ScriptConstants.WINDOWS_COMMAND_RUN + Constants.SPACE);
    res.append(ScriptConstants.WINDOWS_FORCE_MOVE);
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_ACCESS_FILE_PATH_DEFAULT));
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(accessFilePath);
    res.append(Constants.QUOTE_MARK);
    res.append(Constants.NEWLINE);
  }
  if (!passwordFilePath.equals(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_PASSWORD_FILE_PATH_DEFAULT))) {
    res.append(ScriptConstants.SSH + Constants.SPACE);
    res.append(machineUserLogin());
    res.append(Constants.SPACE + Constants.QUOTE_MARK);
    res.append(ScriptConstants.WINDOWS_COMMAND_RUN + Constants.SPACE);
    res.append(ScriptConstants.WINDOWS_FORCE_MOVE);
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_PASSWORD_FILE_PATH_DEFAULT));
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(passwordFilePath);
    res.append(Constants.QUOTE_MARK);
    res.append(Constants.NEWLINE);
  }
  res.append(ScriptConstants.ECHO_Y + Constants.SPACE + Constants.SEPARATOR+ Constants.SPACE+ ScriptConstants.SSH+ Constants.SPACE);
  res.append(machineUserLogin());
  res.append(Constants.SPACE + Constants.QUOTE_MARK + ScriptConstants.WINDOWS_COMMAND_RUN+ Constants.SPACE+ ScriptConstants.CACLS+ Constants.SPACE);
  res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
  res.append(passwordFilePath);
  res.append(Constants.SPACE + ScriptConstants.SLASH_P + Constants.SPACE+ ScriptConstants.BITARKIV_BACKSLASH_BACKSLASH);
  res.append(machineParameters.getMachineUserName().getText());
  res.append(ScriptConstants.COLON_R + Constants.QUOTE_MARK);
  res.append(Constants.NEWLINE);
  res.append(ScriptConstants.ECHO_Y + Constants.SPACE + Constants.SEPARATOR+ Constants.SPACE+ ScriptConstants.SSH+ Constants.SPACE);
  res.append(machineUserLogin());
  res.append(Constants.SPACE + Constants.QUOTE_MARK + ScriptConstants.WINDOWS_COMMAND_RUN+ Constants.SPACE+ ScriptConstants.CACLS+ Constants.SPACE);
  res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
  res.append(accessFilePath);
  res.append(Constants.SPACE + ScriptConstants.SLASH_P + Constants.SPACE+ ScriptConstants.BITARKIV_BACKSLASH_BACKSLASH);
  res.append(machineParameters.getMachineUserName().getText());
  res.append(ScriptConstants.COLON_R + Constants.QUOTE_MARK);
  res.append(Constants.NEWLINE);
  return res.toString();
}

Fixed version (ground truth):
/** 
 * This method does the following: Retrieves the path to the jmxremote.access and jmxremote.password files. Moves these files, if they are different from standard. This has to be a force move (command 'move /Y'). Makes the jmxremote.access and jmxremote.password files readonly.
 * @return The commands for handling the jmxremote files.
 */
@Override protected String getJMXremoteFilesCommand(){
  String accessFilePath;
  String passwordFilePath;
  String[] options;
  options=settings.getLeafValues(Constants.SETTINGS_COMMON_JMX_ACCESSFILE);
  if (options.length == 0) {
    accessFilePath=Constants.JMX_ACCESS_FILE_PATH_DEFAULT;
  }
 else {
    accessFilePath=options[0];
    if (options.length > 1) {
      log.debug(Constants.MSG_WARN_TOO_MANY_JMXREMOTE_FILE_PATHS);
    }
  }
  options=settings.getLeafValues(Constants.SETTINGS_COMMON_JMX_PASSWORDFILE);
  if (options.length == 0) {
    passwordFilePath=Constants.JMX_PASSWORD_FILE_PATH_DEFAULT;
  }
 else {
    passwordFilePath=options[0];
    if (options.length > 1) {
      log.debug(Constants.MSG_WARN_TOO_MANY_JMXREMOTE_FILE_PATHS);
    }
  }
  accessFilePath=ScriptConstants.replaceWindowsDirSeparators(accessFilePath);
  passwordFilePath=ScriptConstants.replaceWindowsDirSeparators(passwordFilePath);
  StringBuilder res=new StringBuilder();
  res.append(ScriptConstants.ECHO_MAKE_PASSWORD_FILES);
  res.append(Constants.NEWLINE);
  if (!accessFilePath.equals(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_ACCESS_FILE_PATH_DEFAULT))) {
    res.append(ScriptConstants.SSH + Constants.SPACE);
    res.append(machineUserLogin());
    res.append(Constants.SPACE + Constants.QUOTE_MARK);
    res.append(ScriptConstants.WINDOWS_COMMAND_RUN + Constants.SPACE);
    res.append(ScriptConstants.WINDOWS_FORCE_MOVE);
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_ACCESS_FILE_PATH_DEFAULT));
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(accessFilePath);
    res.append(Constants.QUOTE_MARK);
    res.append(Constants.NEWLINE);
  }
  if (!passwordFilePath.equals(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_PASSWORD_FILE_PATH_DEFAULT))) {
    res.append(ScriptConstants.SSH + Constants.SPACE);
    res.append(machineUserLogin());
    res.append(Constants.SPACE + Constants.QUOTE_MARK);
    res.append(ScriptConstants.WINDOWS_COMMAND_RUN + Constants.SPACE);
    res.append(ScriptConstants.WINDOWS_FORCE_MOVE);
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(ScriptConstants.replaceWindowsDirSeparators(Constants.JMX_PASSWORD_FILE_PATH_DEFAULT));
    res.append(Constants.SPACE);
    res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
    res.append(passwordFilePath);
    res.append(Constants.QUOTE_MARK);
    res.append(Constants.NEWLINE);
  }
  res.append(ScriptConstants.ECHO_Y + Constants.SPACE + Constants.SEPARATOR+ Constants.SPACE+ ScriptConstants.SSH+ Constants.SPACE);
  res.append(machineUserLogin());
  res.append(Constants.SPACE + Constants.QUOTE_MARK + ScriptConstants.WINDOWS_COMMAND_RUN+ Constants.SPACE+ ScriptConstants.CACLS+ Constants.SPACE);
  res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
  res.append(passwordFilePath);
  res.append(Constants.SPACE + ScriptConstants.SLASH_P + Constants.SPACE+ ScriptConstants.BITARKIV_BACKSLASH_BACKSLASH);
  res.append(machineParameters.getMachineUserName().getText());
  res.append(ScriptConstants.COLON_R + Constants.QUOTE_MARK);
  res.append(Constants.NEWLINE);
  res.append(ScriptConstants.ECHO_Y + Constants.SPACE + Constants.SEPARATOR+ Constants.SPACE+ ScriptConstants.SSH+ Constants.SPACE);
  res.append(machineUserLogin());
  res.append(Constants.SPACE + Constants.QUOTE_MARK + ScriptConstants.WINDOWS_COMMAND_RUN+ Constants.SPACE+ ScriptConstants.CACLS+ Constants.SPACE);
  res.append(ScriptConstants.doubleBackslashes(getLocalInstallDirPath()));
  res.append(accessFilePath);
  res.append(Constants.SPACE + ScriptConstants.SLASH_P + Constants.SPACE+ ScriptConstants.BITARKIV_BACKSLASH_BACKSLASH);
  res.append(machineParameters.getMachineUserName().getText());
  res.append(ScriptConstants.COLON_R + Constants.QUOTE_MARK);
  res.append(Constants.NEWLINE);
  return res.toString();
}