Program: 115573
Project: 115573
Buggy source:
/** 
 * Add a Service Group
 * @param serviceGroupDefinition serviceGroupDefinition
 * @throws InvalidCartridgeGroupDefinitionException
 * @throws RestAPIException
 */
public static void addCartridgeGroup(CartridgeGroupBean serviceGroupDefinition) throws InvalidCartridgeGroupDefinitionException, ServiceGroupDefinitionException, RestAPIException, CloudControllerServiceCartridgeNotFoundExceptionException, AutoscalerServiceInvalidServiceGroupExceptionException {
  if (serviceGroupDefinition == null) {
    throw new RuntimeException("String_Node_Str");
  }
  List<String> cartridgeTypes=new ArrayList<String>();
  String[] cartridgeNames=null;
  List<String> groupNames;
  String[] cartridgeGroupNames;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + serviceGroupDefinition.getUuid());
  }
  findCartridgesInGroupBean(serviceGroupDefinition,cartridgeTypes);
  validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
  validateGroupDuplicationInGroupDefinition(serviceGroupDefinition);
  CloudControllerServiceClient ccServiceClient=getCloudControllerServiceClient();
  cartridgeNames=new String[cartridgeTypes.size()];
  int j=0;
  for (  String cartridgeType : cartridgeTypes) {
    try {
      if (ccServiceClient.getCartridgeByTenant(cartridgeType,serviceGroupDefinition.getTenantId()) == null) {
        log.error("String_Node_Str" + cartridgeType);
        throw new InvalidCartridgeException();
      }
 else {
        cartridgeNames[j]=cartridgeType;
        j++;
      }
    }
 catch (    RemoteException e) {
      String message="String_Node_Str" + serviceGroupDefinition.getUuid();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  if (serviceGroupDefinition.getGroups() != null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + serviceGroupDefinition.getUuid());
    }
    List<CartridgeGroupBean> groupDefinitions=serviceGroupDefinition.getGroups();
    groupNames=new ArrayList<String>();
    cartridgeGroupNames=new String[groupDefinitions.size()];
    int i=0;
    for (    CartridgeGroupBean groupList : groupDefinitions) {
      groupNames.add(groupList.getUuid());
      cartridgeGroupNames[i]=groupList.getUuid();
      i++;
    }
    Set<String> duplicates=findDuplicates(groupNames);
    if (duplicates.size() > 0) {
      StringBuilder duplicatesOutput=new StringBuilder();
      for (      String dup : duplicates) {
        duplicatesOutput.append(dup).append("String_Node_Str");
      }
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + duplicatesOutput.toString());
      }
      throw new InvalidCartridgeGroupDefinitionException("String_Node_Str" + "String_Node_Str" + duplicatesOutput.toString());
    }
  }
  ServiceGroup serviceGroup=ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition);
  AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
  try {
    asServiceClient.addServiceGroup(serviceGroup);
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroupDefinition.getUuid(),cartridgeNames);
  }
 catch (  RemoteException e) {
    String message="String_Node_Str" + serviceGroupDefinition.getUuid();
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
}

Fixed version (ground truth):
/** 
 * Add a Service Group
 * @param serviceGroupDefinition serviceGroupDefinition
 * @throws InvalidCartridgeGroupDefinitionException
 * @throws RestAPIException
 */
public static void addCartridgeGroup(CartridgeGroupBean serviceGroupDefinition) throws InvalidCartridgeGroupDefinitionException, ServiceGroupDefinitionException, RestAPIException, CloudControllerServiceCartridgeNotFoundExceptionException, AutoscalerServiceInvalidServiceGroupExceptionException {
  if (serviceGroupDefinition == null) {
    throw new RuntimeException("String_Node_Str");
  }
  List<String> cartridgeTypes=new ArrayList<String>();
  String[] cartridgeUuids=null;
  List<String> groupNames;
  String[] cartridgeGroupNames;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + serviceGroupDefinition.getUuid());
  }
  findCartridgesInGroupBean(serviceGroupDefinition,cartridgeTypes);
  validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
  validateGroupDuplicationInGroupDefinition(serviceGroupDefinition);
  CloudControllerServiceClient ccServiceClient=getCloudControllerServiceClient();
  cartridgeUuids=new String[cartridgeTypes.size()];
  int j=0;
  for (  String cartridgeType : cartridgeTypes) {
    try {
      Cartridge cartridge=ccServiceClient.getCartridgeByTenant(cartridgeType,serviceGroupDefinition.getTenantId());
      if (cartridge == null) {
        log.error("String_Node_Str" + cartridgeType);
        throw new InvalidCartridgeException();
      }
 else {
        cartridgeUuids[j]=cartridge.getUuid();
        j++;
      }
    }
 catch (    RemoteException e) {
      String message="String_Node_Str" + serviceGroupDefinition.getUuid();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  if (serviceGroupDefinition.getGroups() != null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + serviceGroupDefinition.getUuid());
    }
    List<CartridgeGroupBean> groupDefinitions=serviceGroupDefinition.getGroups();
    groupNames=new ArrayList<String>();
    cartridgeGroupNames=new String[groupDefinitions.size()];
    int i=0;
    for (    CartridgeGroupBean groupList : groupDefinitions) {
      groupNames.add(groupList.getUuid());
      cartridgeGroupNames[i]=groupList.getUuid();
      i++;
    }
    Set<String> duplicates=findDuplicates(groupNames);
    if (duplicates.size() > 0) {
      StringBuilder duplicatesOutput=new StringBuilder();
      for (      String dup : duplicates) {
        duplicatesOutput.append(dup).append("String_Node_Str");
      }
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + duplicatesOutput.toString());
      }
      throw new InvalidCartridgeGroupDefinitionException("String_Node_Str" + "String_Node_Str" + duplicatesOutput.toString());
    }
  }
  ServiceGroup serviceGroup=ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition);
  AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
  try {
    asServiceClient.addServiceGroup(serviceGroup);
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroupDefinition.getUuid(),cartridgeUuids);
  }
 catch (  RemoteException e) {
    String message="String_Node_Str" + serviceGroupDefinition.getUuid();
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
}