Program: 115477
Project: 115477
Buggy source:
/** 
 * Generate configuration for a cluster with the following format: <p/> virtual_server 10.10.10.10 80 { delay_loop 10 lvs_sched wlc lvs_method DR persistence_timeout 5 protocol TCP <p/> real_server 10.10.10.41 80 { weight 50 TCP_CHECK { connect_timeout 3 } } <p/> real_server 10.10.10.42 80 { weight 50 TCP_CHECK { connect_timeout 3 } } }
 * @param cluster
 * @param ports
 * @param text
 */
private void generateConfigurationForCluster(Cluster cluster,Collection<Port> ports,StringBuilder text,StringBuilder virtualIPs,String virtualIPsForServices,String scheduleAlgo,boolean isKeepAlived){
  String commandClear="String_Node_Str";
  try {
    CommandUtils.executeCommand(commandClear);
  }
 catch (  IOException e) {
    if (log.isErrorEnabled()) {
      log.error(String.format("String_Node_Str",commandClear));
    }
    throw new RuntimeException(e);
  }
  String[] virtualIPForServiceArray;
  if (virtualIPsForServices.contains("String_Node_Str")) {
    virtualIPForServiceArray=virtualIPsForServices.split("String_Node_Str");
  }
 else {
    virtualIPForServiceArray=new String[1];
    virtualIPForServiceArray[0]=virtualIPsForServices;
  }
  boolean isServiceAvailable=false;
  for (int i=0; i < virtualIPForServiceArray.length; i++) {
    String[] virtualIpForService=virtualIPForServiceArray[i].split("String_Node_Str");
    for (    Port port : ports) {
      String command="String_Node_Str" + virtualIpForService[1] + "String_Node_Str"+ port.getProxy()+ "String_Node_Str"+ scheduleAlgo;
      try {
        CommandUtils.executeCommand(command);
      }
 catch (      IOException e) {
        if (log.isErrorEnabled()) {
          log.error(String.format("String_Node_Str",command));
        }
        throw new RuntimeException(e);
      }
      for (      String hostname : cluster.getHostNames()) {
        if (virtualIpForService[0].equals(cluster.getServiceName())) {
          text.append("String_Node_Str").append(virtualIpForService[1]).append("String_Node_Str").append(port.getProxy()).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(scheduleAlgo).append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE).append(NEW_LINE);
          for (          Member member : cluster.getMembers()) {
            text.append(TAB).append("String_Node_Str").append(member.getHostName()).append("String_Node_Str").append(port.getValue()).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append("String_Node_Str").append(NEW_LINE);
            String commandMember="String_Node_Str" + virtualIpForService[1] + "String_Node_Str"+ port.getProxy()+ "String_Node_Str"+ member.getHostName()+ "String_Node_Str"+ port.getValue()+ "String_Node_Str";
            try {
              CommandUtils.executeCommand(commandMember);
            }
 catch (            IOException e) {
              if (log.isErrorEnabled()) {
                log.error(String.format("String_Node_Str",commandMember));
              }
              throw new RuntimeException(e);
            }
          }
          text.append("String_Node_Str").append(NEW_LINE);
          isServiceAvailable=true;
          virtualIPs.append(TAB).append(TAB).append(virtualIpForService[1]).append(NEW_LINE);
        }
      }
    }
    if (!isServiceAvailable) {
      log.warn(String.format("String_Node_Str",virtualIpForService[0]));
    }
  }
}

Fixed version (ground truth):
/** 
 * Generate configuration for a cluster with the following format: <p/> virtual_server 10.10.10.10 80 { delay_loop 10 lvs_sched wlc lvs_method DR persistence_timeout 5 protocol TCP <p/> real_server 10.10.10.41 80 { weight 50 TCP_CHECK { connect_timeout 3 } } <p/> real_server 10.10.10.42 80 { weight 50 TCP_CHECK { connect_timeout 3 } } }
 * @param cluster
 * @param text
 */
private void generateConfigurationForCluster(Cluster cluster,StringBuilder text,StringBuilder virtualIPs,String virtualIPsForServices,String scheduleAlgo,boolean isKeepAlived){
  if ((cluster.getMembers() == null) || (cluster.getMembers().size() == 0)) {
    return;
  }
  Member firstMember=(Member)cluster.getMembers().toArray()[0];
  Collection<Port> ports=firstMember.getPorts();
  String commandClear="String_Node_Str";
  try {
    CommandUtils.executeCommand(commandClear);
  }
 catch (  IOException e) {
    if (log.isErrorEnabled()) {
      log.error(String.format("String_Node_Str",commandClear));
    }
    throw new RuntimeException(e);
  }
  String[] virtualIPForServiceArray;
  if (virtualIPsForServices.contains("String_Node_Str")) {
    virtualIPForServiceArray=virtualIPsForServices.split("String_Node_Str");
  }
 else {
    virtualIPForServiceArray=new String[1];
    virtualIPForServiceArray[0]=virtualIPsForServices;
  }
  boolean isServiceAvailable=false;
  for (int i=0; i < virtualIPForServiceArray.length; i++) {
    String[] virtualIpForService=virtualIPForServiceArray[i].split("String_Node_Str");
    for (    Port port : ports) {
      String command="String_Node_Str" + virtualIpForService[1] + "String_Node_Str"+ port.getProxy()+ "String_Node_Str"+ scheduleAlgo;
      try {
        CommandUtils.executeCommand(command);
      }
 catch (      IOException e) {
        if (log.isErrorEnabled()) {
          log.error(String.format("String_Node_Str",command));
        }
        throw new RuntimeException(e);
      }
      for (      String hostname : cluster.getHostNames()) {
        if (virtualIpForService[0].equals(cluster.getServiceName())) {
          text.append("String_Node_Str").append(virtualIpForService[1]).append("String_Node_Str").append(port.getProxy()).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(scheduleAlgo).append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE);
          text.append(TAB).append("String_Node_Str").append(NEW_LINE).append(NEW_LINE);
          for (          Member member : cluster.getMembers()) {
            text.append(TAB).append("String_Node_Str").append(member.getHostName()).append("String_Node_Str").append(port.getValue()).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append(TAB).append("String_Node_Str").append(NEW_LINE);
            text.append(TAB).append("String_Node_Str").append(NEW_LINE);
            String commandMember="String_Node_Str" + virtualIpForService[1] + "String_Node_Str"+ port.getProxy()+ "String_Node_Str"+ member.getHostName()+ "String_Node_Str"+ port.getValue()+ "String_Node_Str";
            try {
              CommandUtils.executeCommand(commandMember);
            }
 catch (            IOException e) {
              if (log.isErrorEnabled()) {
                log.error(String.format("String_Node_Str",commandMember));
              }
              throw new RuntimeException(e);
            }
          }
          text.append("String_Node_Str").append(NEW_LINE);
          isServiceAvailable=true;
          virtualIPs.append(TAB).append(TAB).append(virtualIpForService[1]).append(NEW_LINE);
        }
      }
    }
    if (!isServiceAvailable) {
      log.warn(String.format("String_Node_Str",virtualIpForService[0]));
    }
  }
}