Program: 90030
Project: 90030
Buggy source:
/** 
 * For finding the jmxUsernames and jmxPasswords under the monitor branch in the settings.  Goes through all applications, which all must have the same  username and the same passwords.  
 * @return The string to add to the jmxremote.password file.
 * @throws Exception If there is a different amount of usernames and passwords, or if two application has different values for their username or passwords (applications without values are ignored). 
 */
protected String getMonitorLogin() throws Exception {
  StringBuilder res=new StringBuilder();
  List<String> usernames=new ArrayList<String>();
  List<String> passwords=new ArrayList<String>();
  String[] tmpVals;
  for (  Application app : applications) {
    tmpVals=app.getSettingsValues(Constants.SETTINGS_MONITOR_JMX_NAME_LEAF);
    if (tmpVals != null && tmpVals.length > 0) {
      for (      String st : tmpVals) {
        usernames.add(st);
      }
    }
    tmpVals=app.getSettingsValues(Constants.SETTINGS_MONITOR_JMX_PASSWORD_LEAF);
    if (tmpVals != null && tmpVals.length > 0) {
      for (      String st : tmpVals) {
        passwords.add(st);
      }
    }
  }
  if (usernames.size() != passwords.size()) {
    String msg="String_Node_Str" + "String_Node_Str" + name + "String_Node_Str";
    log.warn(msg);
    throw new Exception(msg);
  }
  if (usernames.size() == 0) {
    String msg="String_Node_Str" + name + "String_Node_Str";
    log.warn(msg);
    throw new IllegalState(msg);
  }
  for (int i=1; i < usernames.size(); i++) {
    if (!usernames.get(0).equals(usernames.get(i)) || !passwords.get(0).equals(passwords.get(i))) {
      String msg="String_Node_Str" + "String_Node_Str" + name + "String_Node_Str";
      log.warn(msg);
      throw new Exception(msg);
    }
  }
  if (usernames.size() > 0) {
    res.append(usernames.get(0));
    res.append(Constants.SPACE);
    res.append(passwords.get(0));
    res.append(Constants.NEWLINE);
  }
  return res.toString();
}

Fixed version (ground truth):
/** 
 * For finding the jmxUsernames and jmxPasswords under the monitor branch in the settings.  Goes through all applications, which all must have the same  username and the same passwords.  
 * @return The string to add to the jmxremote.password file.
 * @throws Exception If there is a different amount of usernames and passwords, or if two application has different values for their username or passwords (applications without values are ignored). 
 */
protected String getMonitorLogin() throws Exception {
  StringBuilder res=new StringBuilder();
  List<String> usernames=new ArrayList<String>();
  List<String> passwords=new ArrayList<String>();
  String[] tmpVals;
  for (  Application app : applications) {
    tmpVals=app.getSettingsValues(Constants.SETTINGS_MONITOR_JMX_NAME_LEAF);
    if (tmpVals != null && tmpVals.length > 0) {
      for (      String st : tmpVals) {
        usernames.add(st);
      }
    }
    tmpVals=app.getSettingsValues(Constants.SETTINGS_MONITOR_JMX_PASSWORD_LEAF);
    if (tmpVals != null && tmpVals.length > 0) {
      for (      String st : tmpVals) {
        passwords.add(st);
      }
    }
  }
  if (usernames.size() != passwords.size()) {
    String msg="String_Node_Str" + "String_Node_Str" + name + "String_Node_Str";
    log.warn(msg);
    throw new Exception(msg);
  }
  if (usernames.size() == 0) {
    log.warn("String_Node_Str" + name + "String_Node_Str");
  }
  for (int i=1; i < usernames.size(); i++) {
    if (!usernames.get(0).equals(usernames.get(i)) || !passwords.get(0).equals(passwords.get(i))) {
      String msg="String_Node_Str" + "String_Node_Str" + name + "String_Node_Str";
      log.warn(msg);
      throw new Exception(msg);
    }
  }
  if (usernames.size() > 0) {
    res.append(usernames.get(0));
    res.append(Constants.SPACE);
    res.append(passwords.get(0));
    res.append(Constants.NEWLINE);
  }
  return res.toString();
}