Program: 49112
Project: 49112
Buggy source:
public boolean validatePlacementPolicies(ClusterCreate cluster,Map<String,NodeGroupCreate> groups,List<String> failedMsgList,List<String> warningMsgList){
  boolean valid=true;
  PlacementPolicy policies=getPlacementPolicies();
  if (policies != null) {
    if (policies.getInstancePerHost() != null) {
      if (policies.getInstancePerHost() <= 0) {
        valid=false;
        failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(policies.getInstancePerHost()).toString());
      }
 else       if (calculateHostNum() < 0) {
        valid=false;
        failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(policies.getInstancePerHost()).append("String_Node_Str").toString());
      }
    }
    if (policies.getGroupRacks() != null) {
      if (cluster.getTopologyPolicy() == null) {
        warningMsgList.add("String_Node_Str" + Constants.PRACK_NO_TOPOLOGY_TYPE_SPECIFIED);
        cluster.setTopologyPolicy(TopologyType.NONE);
      }
      GroupRacks r=policies.getGroupRacks();
      if (r.getType() == null) {
        r.setType(GroupRacksType.ROUNDROBIN);
      }
 else       if (r.getType() == GroupRacksType.SAMERACK && r.getRacks().length != 1) {
        valid=false;
        failedMsgList.add(Constants.PRACK_SAME_RACK_WITH_WRONG_VALUES);
      }
      if (getStorage() == null || getStorage().getType() == null || getStorage().getType().equals(DatastoreType.SHARED.toString())) {
        warningMsgList.add("String_Node_Str" + Constants.PRACK_WITH_SHARED_STORAGE);
      }
    }
    if (policies.getGroupAssociations() != null) {
      if (policies.getGroupAssociations().size() != 1) {
        valid=false;
        failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").toString());
      }
 else {
        GroupAssociation a=policies.getGroupAssociations().get(0);
        if (a.getType() == null) {
          a.setType(GroupAssociationType.WEAK);
        }
        if (a.getReference() == null) {
          valid=false;
          failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").toString());
        }
 else         if (a.getReference().equals(getName())) {
          valid=false;
          failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").toString());
        }
 else         if (!groups.containsKey(a.getReference())) {
          valid=false;
          failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(a.getReference()).toString());
        }
 else {
          if (a.getType() == GroupAssociationType.STRICT) {
            if (policies.getGroupRacks() != null) {
              warningMsgList.add("String_Node_Str" + Constants.PRACK_WITH_STRICT_ASSOCIATION);
            }
            int hostNum=1;
            int refHostNum=groups.get(a.getReference()).getInstanceNum();
            if (calculateHostNum() != null) {
              hostNum=calculateHostNum();
            }
            if (groups.get(a.getReference()).calculateHostNum() != null) {
              refHostNum=groups.get(a.getReference()).calculateHostNum();
            }
            if (hostNum > refHostNum) {
              valid=false;
              failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str" + "String_Node_Str").append(a.getReference()).toString());
            }
          }
          PlacementPolicy refPolicies=groups.get(a.getReference()).getPlacementPolicies();
          if (refPolicies != null && refPolicies.getGroupAssociations() != null && !refPolicies.getGroupAssociations().isEmpty()) {
            valid=false;
            failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(a.getReference()).append("String_Node_Str").toString());
          }
        }
      }
    }
  }
  return valid;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public boolean validatePlacementPolicies(ClusterCreate cluster,Map<String,NodeGroupCreate> groups,List<String> failedMsgList,List<String> warningMsgList){
  boolean valid=true;
  if (cluster.getTopologyPolicy() == TopologyType.HVE || cluster.getTopologyPolicy() == TopologyType.HOST_AS_RACK || cluster.getTopologyPolicy() == TopologyType.RACK_AS_RACK) {
    if (getPlacementPolicies() == null) {
      setPlacementPolicies(new PlacementPolicy());
    }
    if (getPlacementPolicies().getGroupRacks() == null) {
      GroupRacks groupRacks=new GroupRacks();
      groupRacks.setType(GroupRacksType.ROUNDROBIN);
      groupRacks.setRacks(new String[0]);
      getPlacementPolicies().setGroupRacks(groupRacks);
    }
  }
  PlacementPolicy policies=getPlacementPolicies();
  if (policies != null) {
    if (policies.getInstancePerHost() != null) {
      if (policies.getInstancePerHost() <= 0) {
        valid=false;
        failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(policies.getInstancePerHost()).toString());
      }
 else       if (calculateHostNum() < 0) {
        valid=false;
        failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(policies.getInstancePerHost()).append("String_Node_Str").toString());
      }
    }
    if (policies.getGroupRacks() != null) {
      if (cluster.getTopologyPolicy() == null) {
        warningMsgList.add("String_Node_Str" + Constants.PRACK_NO_TOPOLOGY_TYPE_SPECIFIED);
        cluster.setTopologyPolicy(TopologyType.NONE);
      }
      GroupRacks r=policies.getGroupRacks();
      if (r.getType() == null) {
        r.setType(GroupRacksType.ROUNDROBIN);
      }
 else       if (r.getType() == GroupRacksType.SAMERACK && r.getRacks().length != 1) {
        valid=false;
        failedMsgList.add(Constants.PRACK_SAME_RACK_WITH_WRONG_VALUES);
      }
      if (r.getRacks() == null) {
        r.setRacks(new String[0]);
      }
      if (getStorage() == null || getStorage().getType() == null || getStorage().getType().equals(DatastoreType.SHARED.toString())) {
        warningMsgList.add("String_Node_Str" + Constants.PRACK_WITH_SHARED_STORAGE);
      }
    }
    if (policies.getGroupAssociations() != null) {
      if (policies.getGroupAssociations().size() != 1) {
        valid=false;
        failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").toString());
      }
 else {
        GroupAssociation a=policies.getGroupAssociations().get(0);
        if (a.getType() == null) {
          a.setType(GroupAssociationType.WEAK);
        }
        if (a.getReference() == null) {
          valid=false;
          failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").toString());
        }
 else         if (a.getReference().equals(getName())) {
          valid=false;
          failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").toString());
        }
 else         if (!groups.containsKey(a.getReference())) {
          valid=false;
          failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(a.getReference()).toString());
        }
 else {
          if (a.getType() == GroupAssociationType.STRICT) {
            if (policies.getGroupRacks() != null) {
              warningMsgList.add("String_Node_Str" + Constants.PRACK_WITH_STRICT_ASSOCIATION);
            }
            int hostNum=1;
            int refHostNum=groups.get(a.getReference()).getInstanceNum();
            if (calculateHostNum() != null) {
              hostNum=calculateHostNum();
            }
            if (groups.get(a.getReference()).calculateHostNum() != null) {
              refHostNum=groups.get(a.getReference()).calculateHostNum();
            }
            if (hostNum > refHostNum) {
              valid=false;
              failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str" + "String_Node_Str").append(a.getReference()).toString());
            }
          }
          PlacementPolicy refPolicies=groups.get(a.getReference()).getPlacementPolicies();
          if (refPolicies != null && refPolicies.getGroupAssociations() != null && !refPolicies.getGroupAssociations().isEmpty()) {
            valid=false;
            failedMsgList.add(new StringBuilder().append(getName()).append("String_Node_Str").append(a.getReference()).append("String_Node_Str").toString());
          }
        }
      }
    }
  }
  return valid;
}