Program: 48587
Project: 48587
Buggy source:
public static void expandGroupInstanceType(NodeGroupEntity ngEntity,NodeGroupCreate group,Set<String> sharedPattern,Set<String> localPattern){
  logger.debug("String_Node_Str" + ngEntity.getName());
  InstanceType instanceType=ngEntity.getNodeType();
  int memory=ngEntity.getMemorySize();
  int cpu=ngEntity.getCpuNum();
  if (instanceType == null && (cpu == 0 || memory == 0)) {
    throw ClusterConfigException.INSTANCE_SIZE_NOT_SET(group.getName());
  }
  if (instanceType == null) {
    logger.debug("String_Node_Str");
  }
 else {
    logger.debug("String_Node_Str" + instanceType.toString());
  }
  if (memory == 0) {
    ngEntity.setMemorySize(instanceType.getMemoryMB());
  }
  if (cpu == 0) {
    ngEntity.setCpuNum(instanceType.getCpuNum());
  }
  logger.debug("String_Node_Str" + ngEntity.getStorageSize());
  if (ngEntity.getStorageType() == null) {
    String expectedType=group.getStorage().getExpectedTypeFromRoles();
    DatastoreType storeType=DatastoreType.valueOf(expectedType);
    if ((sharedPattern == null || sharedPattern.isEmpty()) && DatastoreType.SHARED == storeType) {
      storeType=DatastoreType.LOCAL;
    }
    if ((localPattern == null || localPattern.isEmpty()) && DatastoreType.LOCAL == storeType) {
      storeType=DatastoreType.SHARED;
    }
    ngEntity.setStorageType(storeType);
  }
 else {
    if ((sharedPattern == null || sharedPattern.isEmpty()) && (ngEntity.getStorageType().equals(DatastoreType.SHARED))) {
      String msg="String_Node_Str" + ngEntity.getName() + "String_Node_Str";
      logger.error(msg);
      throw ClusterConfigException.CLUSTER_CONFIG_DATASTORE_TYPE_NONEXISTENT(msg);
    }
    if ((localPattern == null || localPattern.isEmpty()) && (ngEntity.getStorageType().equals(DatastoreType.LOCAL))) {
      String msg="String_Node_Str" + ngEntity.getName() + "String_Node_Str";
      logger.error(msg);
      throw ClusterConfigException.CLUSTER_CONFIG_DATASTORE_TYPE_NONEXISTENT(msg);
    }
  }
}

Fixed version (ground truth):
public static void expandGroupInstanceType(NodeGroupEntity ngEntity,NodeGroupCreate group,Set<String> sharedPattern,Set<String> localPattern,SoftwareManager softwareManager){
  logger.debug("String_Node_Str" + ngEntity.getName());
  InstanceType instanceType=ngEntity.getNodeType();
  int memory=ngEntity.getMemorySize();
  int cpu=ngEntity.getCpuNum();
  if (instanceType == null && (cpu == 0 || memory == 0)) {
    throw ClusterConfigException.INSTANCE_SIZE_NOT_SET(group.getName());
  }
  if (instanceType == null) {
    logger.debug("String_Node_Str");
    if (softwareManager.hasMgmtRole(group.getRoles())) {
      instanceType=InstanceType.MEDIUM;
    }
 else {
      instanceType=InstanceType.SMALL;
    }
    ngEntity.setNodeType(instanceType);
  }
 else {
    logger.debug("String_Node_Str" + instanceType.toString());
  }
  if (group.getStorage().getSizeGB() <= 0) {
    GroupType groupType=null;
    if (softwareManager.hasMgmtRole(group.getRoles())) {
      groupType=GroupType.MANAGEMENTGROUP;
    }
 else {
      groupType=GroupType.WORKGROUP;
    }
    ngEntity.setStorageSize(ExpandUtils.getStorage(instanceType,groupType));
    logger.debug("String_Node_Str" + ngEntity.getStorageSize());
  }
 else {
    ngEntity.setStorageSize(group.getStorage().getSizeGB());
  }
  if (memory == 0) {
    ngEntity.setMemorySize(instanceType.getMemoryMB());
  }
  if (cpu == 0) {
    ngEntity.setCpuNum(instanceType.getCpuNum());
  }
  logger.debug("String_Node_Str" + ngEntity.getStorageSize());
  if (ngEntity.getStorageType() == null) {
    DatastoreType storeType=null;
    if (softwareManager.hasMgmtRole(group.getRoles())) {
      storeType=DatastoreType.SHARED;
    }
 else {
      storeType=DatastoreType.LOCAL;
    }
    if ((sharedPattern == null || sharedPattern.isEmpty()) && DatastoreType.SHARED == storeType) {
      storeType=DatastoreType.LOCAL;
    }
    if ((localPattern == null || localPattern.isEmpty()) && DatastoreType.LOCAL == storeType) {
      storeType=DatastoreType.SHARED;
    }
    ngEntity.setStorageType(storeType);
  }
 else {
    if ((sharedPattern == null || sharedPattern.isEmpty()) && (ngEntity.getStorageType().equals(DatastoreType.SHARED))) {
      String msg="String_Node_Str" + ngEntity.getName() + "String_Node_Str";
      logger.error(msg);
      throw ClusterConfigException.CLUSTER_CONFIG_DATASTORE_TYPE_NONEXISTENT(msg);
    }
    if ((localPattern == null || localPattern.isEmpty()) && (ngEntity.getStorageType().equals(DatastoreType.LOCAL))) {
      String msg="String_Node_Str" + ngEntity.getName() + "String_Node_Str";
      logger.error(msg);
      throw ClusterConfigException.CLUSTER_CONFIG_DATASTORE_TYPE_NONEXISTENT(msg);
    }
  }
}