Program: 115981
Project: 115981
Buggy source:
public static void addServiceGroup(GroupBean serviceGroupDefinition) throws RestAPIException {
  try {
    if (serviceGroupDefinition == null) {
      throw new RuntimeException("String_Node_Str");
    }
    List<String> cartridgeTypes=null;
    List<String> groupNames=null;
    if (serviceGroupDefinition.getCartridges() != null) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + serviceGroupDefinition.getName());
      }
      cartridgeTypes=serviceGroupDefinition.getCartridges();
      Set<String> duplicates=findDuplicates(cartridgeTypes);
      if (duplicates.size() > 0) {
        StringBuffer buf=new StringBuffer();
        for (        String dup : duplicates) {
          buf.append(dup).append("String_Node_Str");
        }
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + buf.toString());
        }
        throw new RestAPIException("String_Node_Str" + buf.toString());
      }
      CloudControllerServiceClient ccServiceClient=getCloudControllerServiceClient();
      for (      String cartridgeType : cartridgeTypes) {
        try {
          if (ccServiceClient.getCartridgeInfo(cartridgeType) == null) {
            log.error("String_Node_Str" + cartridgeType);
            throw new RestAPIException("String_Node_Str" + cartridgeType);
          }
        }
 catch (        RemoteException e) {
          throw new RestAPIException(e);
        }
catch (        CloudControllerServiceCartridgeNotFoundExceptionException e) {
          throw new RestAPIException(e);
        }
      }
    }
    if (serviceGroupDefinition.getGroups() != null) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + serviceGroupDefinition.getName());
      }
      List<GroupBean> groupDefinitions=serviceGroupDefinition.getGroups();
      groupNames=new ArrayList<String>();
      for (      GroupBean groupList : groupDefinitions) {
        groupNames.add(groupList.getName());
      }
      Set<String> duplicates=findDuplicates(groupNames);
      if (duplicates.size() > 0) {
        StringBuffer buf=new StringBuffer();
        for (        String dup : duplicates) {
          buf.append(dup).append("String_Node_Str");
        }
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + buf.toString());
        }
        throw new RestAPIException("String_Node_Str" + buf.toString());
      }
    }
    ServiceGroup serviceGroup=ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition);
    AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
    asServiceClient.addServiceGroup(serviceGroup);
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    if (cartridgeTypes != null) {
      smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroupDefinition.getName(),(String[])cartridgeTypes.toArray());
    }
    if (groupNames != null) {
      smServiceClient.addUsedCartridgeGroupsInCartridgeSubGroups(serviceGroupDefinition.getName(),(String[])groupNames.toArray());
    }
  }
 catch (  Exception e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
}

Fixed version (ground truth):
public static void addServiceGroup(GroupBean serviceGroupDefinition) throws RestAPIException {
  try {
    if (serviceGroupDefinition == null) {
      throw new RuntimeException("String_Node_Str");
    }
    List<String> cartridgeTypes=null;
    String[] cartridgeNames=null;
    List<String> groupNames=null;
    String[] cartridgeGroupNames=null;
    if (serviceGroupDefinition.getCartridges() != null) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + serviceGroupDefinition.getName());
      }
      cartridgeTypes=serviceGroupDefinition.getCartridges();
      Set<String> duplicates=findDuplicates(cartridgeTypes);
      if (duplicates.size() > 0) {
        StringBuffer buf=new StringBuffer();
        for (        String dup : duplicates) {
          buf.append(dup).append("String_Node_Str");
        }
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + buf.toString());
        }
        throw new RestAPIException("String_Node_Str" + buf.toString());
      }
      CloudControllerServiceClient ccServiceClient=getCloudControllerServiceClient();
      cartridgeNames=new String[cartridgeTypes.size()];
      int i=0;
      for (      String cartridgeType : cartridgeTypes) {
        try {
          if (ccServiceClient.getCartridgeInfo(cartridgeType) == null) {
            log.error("String_Node_Str" + cartridgeType);
            throw new RestAPIException("String_Node_Str" + cartridgeType);
          }
 else {
            cartridgeNames[i]=cartridgeType;
            i++;
          }
        }
 catch (        RemoteException e) {
          throw new RestAPIException(e);
        }
catch (        CloudControllerServiceCartridgeNotFoundExceptionException e) {
          throw new RestAPIException(e);
        }
      }
    }
    if (serviceGroupDefinition.getGroups() != null) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + serviceGroupDefinition.getName());
      }
      List<GroupBean> groupDefinitions=serviceGroupDefinition.getGroups();
      groupNames=new ArrayList<String>();
      cartridgeGroupNames=new String[groupNames.size()];
      int i=0;
      for (      GroupBean groupList : groupDefinitions) {
        groupNames.add(groupList.getName());
        cartridgeGroupNames[i]=groupList.getName();
        i++;
      }
      Set<String> duplicates=findDuplicates(groupNames);
      if (duplicates.size() > 0) {
        StringBuffer buf=new StringBuffer();
        for (        String dup : duplicates) {
          buf.append(dup).append("String_Node_Str");
        }
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + buf.toString());
        }
        throw new RestAPIException("String_Node_Str" + buf.toString());
      }
    }
    ServiceGroup serviceGroup=ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition);
    AutoscalerServiceClient asServiceClient=getAutoscalerServiceClient();
    asServiceClient.addServiceGroup(serviceGroup);
    StratosManagerServiceClient smServiceClient=getStratosManagerServiceClient();
    if (cartridgeTypes != null) {
      smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroupDefinition.getName(),cartridgeNames);
    }
    if (groupNames != null) {
      smServiceClient.addUsedCartridgeGroupsInCartridgeSubGroups(serviceGroupDefinition.getName(),cartridgeGroupNames);
    }
  }
 catch (  Exception e) {
    String message="String_Node_Str";
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
}