Program: 115500
Project: 115500
Buggy source:
/** 
 * Add a Service Group
 * @param serviceGroupDefinition serviceGroupDefinition
 * @throws InvalidCartridgeGroupDefinitionException
 * @throws RestAPIException
 */
public static void addCartridgeGroup(CartridgeGroupBean serviceGroupDefinition,String cartridgeGroupUuid,int tenantId) throws InvalidCartridgeGroupDefinitionException, ServiceGroupDefinitionException, RestAPIException, CloudControllerServiceCartridgeNotFoundExceptionException, AutoscalerServiceInvalidServiceGroupExceptionException {
  if (serviceGroupDefinition == null) {
    throw new RuntimeException("String_Node_Str");
  }
  List<String> cartridgeTypes=new ArrayList<String>();
  String[] cartridgeUuids;
  List<String> groupNames;
  String[] cartridgeGroupNames;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + cartridgeGroupUuid);
  }
  ServiceGroup serviceGroup=ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition,UUID.randomUUID().toString(),tenantId);
  findCartridgesInGroupBean(serviceGroup,cartridgeTypes);
  validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
  try {
    validateGroupDuplicationInGroupDefinition(serviceGroupDefinition);
  }
 catch (  RemoteException e) {
    String message="String_Node_Str" + cartridgeGroupUuid;
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
  CloudControllerServiceClient ccServiceClient=getCloudControllerServiceClient();
  cartridgeUuids=new String[cartridgeTypes.size()];
  int j=0;
  for (  String cartridgeType : cartridgeTypes) {
    try {
      Cartridge cartridge=ccServiceClient.getCartridgeByTenant(cartridgeType,tenantId);
      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" + cartridgeGroupUuid;
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  if (serviceGroupDefinition.getGroups() != null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + cartridgeGroupUuid);
    }
    List<CartridgeGroupBean> groupDefinitions=serviceGroupDefinition.getGroups();
    groupNames=new ArrayList<String>();
    cartridgeGroupNames=new String[groupDefinitions.size()];
    int i=0;
    for (    CartridgeGroupBean groupList : groupDefinitions) {
      groupNames.add(groupList.getName());
      cartridgeGroupNames[i]=groupList.getName();
      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());
    }
  }
  AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
  try {
    asServiceClient.addServiceGroup(serviceGroup);
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroup.getUuid(),cartridgeUuids);
  }
 catch (  RemoteException e) {
    String message=String.format("String_Node_Str" + "String_Node_Str",serviceGroup.getUuid(),serviceGroupDefinition.getName());
    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,String cartridgeGroupUuid,int tenantId) throws InvalidCartridgeGroupDefinitionException, ServiceGroupDefinitionException, RestAPIException, CloudControllerServiceCartridgeNotFoundExceptionException, AutoscalerServiceInvalidServiceGroupExceptionException {
  if (serviceGroupDefinition == null) {
    throw new RuntimeException("String_Node_Str");
  }
  List<String> cartridgeTypes=new ArrayList<String>();
  String[] cartridgeUuids;
  List<String> groupNames;
  String[] cartridgeGroupNames;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + cartridgeGroupUuid);
  }
  ServiceGroup serviceGroup=ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition,UUID.randomUUID().toString(),tenantId);
  try {
    findCartridgesInGroupBean(serviceGroup,cartridgeTypes);
  }
 catch (  RemoteException e) {
    throw new RestAPIException(e.getMessage());
  }
  validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
  try {
    validateGroupDuplicationInGroupDefinition(serviceGroupDefinition);
  }
 catch (  RemoteException e) {
    String message="String_Node_Str" + cartridgeGroupUuid;
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
  cartridgeUuids=new String[cartridgeTypes.size()];
  int j=0;
  for (  String cartridgeUuid : cartridgeTypes) {
    cartridgeUuids[j]=cartridgeUuid;
    j++;
  }
  if (serviceGroupDefinition.getGroups() != null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + cartridgeGroupUuid);
    }
    List<CartridgeGroupBean> groupDefinitions=serviceGroupDefinition.getGroups();
    groupNames=new ArrayList<String>();
    cartridgeGroupNames=new String[groupDefinitions.size()];
    int i=0;
    for (    CartridgeGroupBean groupList : groupDefinitions) {
      groupNames.add(groupList.getName());
      cartridgeGroupNames[i]=groupList.getName();
      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());
    }
  }
  AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
  try {
    asServiceClient.addServiceGroup(serviceGroup);
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroup.getUuid(),cartridgeUuids);
  }
 catch (  RemoteException e) {
    String message=String.format("String_Node_Str" + "String_Node_Str",serviceGroup.getUuid(),serviceGroupDefinition.getName());
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
}