Program: 48902
Project: 48902
Buggy source:
public boolean validatePlacementPolicies(ClusterCreate cluster,Map<String,NodeGroupCreate> groups,List<String> failedMsgList,List<String> warningMsgList){
  boolean valid=true;
  TopologyType topologyType=cluster.getTopologyPolicy();
  if (topologyType != null && (topologyType.equals(TopologyType.HVE) || topologyType.equals(TopologyType.RACK_AS_RACK)) && isWorkerGroup()) {
    if (getPlacementPolicies() == null) {
      setPlacementPolicies(new PlacementPolicy());
    }
    if (getPlacementPolicies().getGroupRacks() == null && getPlacementPolicies().getGroupAssociations() == 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) {
      GroupRacks r=policies.getGroupRacks();
      if (r.getType() == null) {
        r.setType(GroupRacksType.ROUNDROBIN);
      }
      if (r.getRacks() == null) {
        r.setRacks(new String[0]);
      }
      if (getStorage() != null && getStorage().getType() != null && getStorage().getType().equals(DatastoreType.SHARED.toString())) {
        warningMsgList.add(new StringBuilder().append("String_Node_Str").append(getName()).append("String_Node_Str").toString());
      }
    }
    if (policies.getGroupAssociations() != null) {
      if (policies.getGroupRacks() != null) {
        warningMsgList.add(new StringBuilder().append("String_Node_Str").append(getName()).append("String_Node_Str").toString());
      }
      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()).append("String_Node_Str").toString());
        }
 else {
          if (a.getType() == GroupAssociationType.STRICT) {
            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()).append("String_Node_Str").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):
public boolean validatePlacementPolicies(ClusterCreate cluster,Map<String,NodeGroupCreate> groups,List<String> failedMsgList,List<String> warningMsgList){
  boolean valid=true;
  TopologyType topologyType=cluster.getTopologyPolicy();
  if (topologyType != null && (topologyType.equals(TopologyType.HVE) || topologyType.equals(TopologyType.RACK_AS_RACK)) && isWorkerGroup()) {
    if (getPlacementPolicies() == null) {
      setPlacementPolicies(new PlacementPolicy());
    }
    if (getPlacementPolicies().getGroupRacks() == null && getPlacementPolicies().getGroupAssociations() == 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()).append("String_Node_Str").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) {
      GroupRacks r=policies.getGroupRacks();
      if (r.getType() == null) {
        r.setType(GroupRacksType.ROUNDROBIN);
      }
      if (r.getRacks() == null) {
        r.setRacks(new String[0]);
      }
      if (getStorage() != null && getStorage().getType() != null && getStorage().getType().equals(DatastoreType.SHARED.toString())) {
        warningMsgList.add(new StringBuilder().append("String_Node_Str").append(getName()).append("String_Node_Str").toString());
      }
    }
    if (policies.getGroupAssociations() != null) {
      if (policies.getGroupRacks() != null) {
        warningMsgList.add(new StringBuilder().append("String_Node_Str").append(getName()).append("String_Node_Str").toString());
      }
      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()).append("String_Node_Str").toString());
        }
 else {
          if (a.getType() == GroupAssociationType.STRICT) {
            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()).append("String_Node_Str").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;
}