Program: 116092
Project: 116092
Buggy source:
private ServiceGroup populateServiceGroupPojo(ServiceGroupDefinition serviceGroupDefinition) throws ServiceGroupDefinitioException {
  ServiceGroup servicegroup=new ServiceGroup();
  servicegroup.setGroupscalingEnabled(serviceGroupDefinition.isGroupScalingEnabled());
  List<ServiceGroupDefinition> groupsDef=serviceGroupDefinition.getGroups();
  List<String> cartridgesDef=serviceGroupDefinition.getCartridges();
  servicegroup.setName(serviceGroupDefinition.getName());
  if (groupsDef == null) {
    groupsDef=new ArrayList<ServiceGroupDefinition>(0);
  }
  if (cartridgesDef == null) {
    cartridgesDef=new ArrayList<String>(0);
  }
  ServiceGroup[] subGroups=new ServiceGroup[groupsDef.size()];
  String[] cartridges=new String[cartridgesDef.size()];
  for (  ServiceGroupDefinition groupDefinition : groupsDef) {
    int i=0;
    subGroups[i]=populateServiceGroupPojo(groupDefinition);
    ++i;
  }
  servicegroup.setGroups(subGroups);
  cartridges=cartridgesDef.toArray(cartridges);
  servicegroup.setCartridges(cartridges);
  DependencyDefinitions depDefs=serviceGroupDefinition.getDependencies();
  if (depDefs != null) {
    Dependencies deps=new Dependencies();
    List<String> startupOrdersDef=depDefs.getStartupOrders();
    if (startupOrdersDef != null) {
      String[] startupOrders=new String[startupOrdersDef.size()];
      startupOrders=startupOrdersDef.toArray(startupOrders);
      deps.setStartupOrders(startupOrders);
    }
    validateTerminationBehavior(depDefs.getTerminationBehaviour());
    deps.setTerminationBehaviour(depDefs.getTerminationBehaviour());
    if (depDefs.getScalingDependants() != null) {
      deps.setScalingDependants(depDefs.getScalingDependants().toArray(new String[depDefs.getScalingDependants().size()]));
    }
    servicegroup.setDependencies(deps);
  }
  return servicegroup;
}

Fixed version (ground truth):
private ServiceGroup populateServiceGroupPojo(ServiceGroupDefinition serviceGroupDefinition) throws ServiceGroupDefinitioException {
  ServiceGroup servicegroup=new ServiceGroup();
  servicegroup.setGroupscalingEnabled(serviceGroupDefinition.isGroupScalingEnabled());
  List<ServiceGroupDefinition> groupsDef=serviceGroupDefinition.getGroups();
  List<String> cartridgesDef=serviceGroupDefinition.getCartridges();
  servicegroup.setName(serviceGroupDefinition.getName());
  if (groupsDef == null) {
    groupsDef=new ArrayList<ServiceGroupDefinition>(0);
  }
  if (cartridgesDef == null) {
    cartridgesDef=new ArrayList<String>(0);
  }
  ServiceGroup[] subGroups=new ServiceGroup[groupsDef.size()];
  String[] cartridges=new String[cartridgesDef.size()];
  int i=0;
  for (  ServiceGroupDefinition groupDefinition : groupsDef) {
    subGroups[i]=populateServiceGroupPojo(groupDefinition);
    ++i;
  }
  servicegroup.setGroups(subGroups);
  cartridges=cartridgesDef.toArray(cartridges);
  servicegroup.setCartridges(cartridges);
  DependencyDefinitions depDefs=serviceGroupDefinition.getDependencies();
  if (depDefs != null) {
    Dependencies deps=new Dependencies();
    List<String> startupOrdersDef=depDefs.getStartupOrders();
    if (startupOrdersDef != null) {
      String[] startupOrders=new String[startupOrdersDef.size()];
      startupOrders=startupOrdersDef.toArray(startupOrders);
      deps.setStartupOrders(startupOrders);
    }
    validateTerminationBehavior(depDefs.getTerminationBehaviour());
    deps.setTerminationBehaviour(depDefs.getTerminationBehaviour());
    if (depDefs.getScalingDependants() != null) {
      deps.setScalingDependants(depDefs.getScalingDependants().toArray(new String[depDefs.getScalingDependants().size()]));
    }
    servicegroup.setDependencies(deps);
  }
  return servicegroup;
}