nus-yam/ex-repair huggingface dataset:
Program: 115700
Project: 115700
Buggy source:
/** 
 * Find Cartridges In ServiceGroup
 * @param serviceGroup serviceGroup
 * @param cartridges   List of cartridges
 */
private static void findCartridgesInServiceGroup(ServiceGroup serviceGroup,List<String> cartridges){
  if (serviceGroup == null || cartridges == null) {
    return;
  }
  if (serviceGroup.getCartridges() != null) {
    for (    String cartridge : serviceGroup.getCartridges()) {
      if (cartridge != null && cartridges.contains(cartridge)) {
        cartridges.add(cartridge);
      }
    }
  }
  if (serviceGroup.getGroups() != null) {
    for (    ServiceGroup seGroup : serviceGroup.getGroups()) {
      findCartridgesInServiceGroup(seGroup,cartridges);
    }
  }
}

Fixed version (ground truth):
/** 
 * Find Cartridges In ServiceGroup
 * @param serviceGroup serviceGroup
 * @param cartridges   List of cartridges
 */
private static void findCartridgesInServiceGroup(ServiceGroup serviceGroup,List<String> cartridges){
  if (serviceGroup == null || cartridges == null) {
    return;
  }
  if (serviceGroup.getCartridges() != null) {
    for (    String cartridge : serviceGroup.getCartridges()) {
      if (cartridge != null && (!cartridges.contains(cartridge))) {
        cartridges.add(cartridge);
      }
    }
  }
  if (serviceGroup.getGroups() != null) {
    for (    ServiceGroup seGroup : serviceGroup.getGroups()) {
      findCartridgesInServiceGroup(seGroup,cartridges);
    }
  }
}
Program: 115701
Project: 115701
Buggy source:
/** 
 * Convert scaling factor string to its enumeration
 * @param scalingFactorStr scaling factor string
 * @return scaling factor enumeration
 */
private static MockScalingFactor convertScalingFactor(String scalingFactorStr){
  if ("String_Node_Str".equals(scalingFactorStr)) {
    return MockScalingFactor.MemoryConsumption;
  }
 else   if ("String_Node_Str".equals(scalingFactorStr)) {
    return MockScalingFactor.LoadAverage;
  }
 else   if ("String_Node_Str".equals(scalingFactorStr)) {
    return MockScalingFactor.RequestInFlight;
  }
  throw new RuntimeException("String_Node_Str" + scalingFactorStr);
}

Fixed version (ground truth):
/** 
 * Convert scaling factor string to its enumeration
 * @param scalingFactorStr scaling factor string
 * @return scaling factor enumeration
 */
private static MockScalingFactor convertScalingFactor(String scalingFactorStr){
  if ("String_Node_Str".equals(scalingFactorStr)) {
    return MockScalingFactor.MemoryConsumption;
  }
 else   if ("String_Node_Str".equals(scalingFactorStr)) {
    return MockScalingFactor.LoadAverage;
  }
 else   if ("String_Node_Str".equals(scalingFactorStr)) {
    return MockScalingFactor.RequestsInFlight;
  }
  throw new RuntimeException("String_Node_Str" + scalingFactorStr);
}
Program: 115702
Project: 115702
Buggy source:
/** 
 * Find default statistics value of the given autoscaling factor
 * @param scalingFactor
 * @return
 */
private int findDefault(MockScalingFactor scalingFactor){
  if (scalingFactor == MockScalingFactor.MemoryConsumption) {
    return DEFAULT_MEMORY_CONSUMPTION;
  }
 else   if (scalingFactor == MockScalingFactor.LoadAverage) {
    return DEFAULT_LOAD_AVERAGE;
  }
 else   if (scalingFactor == MockScalingFactor.RequestInFlight) {
    return DEFAULT_REQUESTS_IN_FLIGHT;
  }
  throw new RuntimeException("String_Node_Str" + scalingFactor);
}

Fixed version (ground truth):
/** 
 * Find default statistics value of the given scaling factor
 * @param scalingFactor
 * @return
 */
private int findDefault(MockScalingFactor scalingFactor){
  if (scalingFactor == MockScalingFactor.MemoryConsumption) {
    return DEFAULT_MEMORY_CONSUMPTION;
  }
 else   if (scalingFactor == MockScalingFactor.LoadAverage) {
    return DEFAULT_LOAD_AVERAGE;
  }
 else   if (scalingFactor == MockScalingFactor.RequestsInFlight) {
    return DEFAULT_REQUESTS_IN_FLIGHT;
  }
  throw new RuntimeException("String_Node_Str" + scalingFactor);
}
Program: 115703
Project: 115703
Buggy source:
/** 
 * Returns current statistics of the given cartridge type, autoscaling factor
 * @param cartridgeType
 * @param scalingFactor
 * @return
 */
public int getStatistics(String cartridgeType,MockScalingFactor scalingFactor) throws NoStatisticsFoundException {
  Map<String,Integer> factorValueMap=statisticsMap.get(cartridgeType);
  if (factorValueMap != null) {
    if (factorValueMap.containsKey(scalingFactor.toString())) {
      return factorValueMap.get(scalingFactor.toString());
    }
 else {
      throw new NoStatisticsFoundException();
    }
  }
  return findDefault(scalingFactor);
}

Fixed version (ground truth):
/** 
 * Returns current statistics of the given cartridge type, scaling factor
 * @param cartridgeType
 * @param scalingFactor
 * @return
 */
public int getStatistics(String cartridgeType,MockScalingFactor scalingFactor) throws NoStatisticsFoundException {
  Map<String,Integer> factorValueMap=statisticsMap.get(cartridgeType);
  if (factorValueMap != null) {
    if (factorValueMap.containsKey(scalingFactor.toString())) {
      return factorValueMap.get(scalingFactor.toString());
    }
 else {
      throw new NoStatisticsFoundException();
    }
  }
  return findDefault(scalingFactor);
}
Program: 115704
Project: 115704
Buggy source:
/** 
 * Remove statistics found for the cartridge type, autoscaling factor
 * @param cartridgeType
 * @param scalingFactor
 */
public void removeStatistics(String cartridgeType,MockScalingFactor scalingFactor){
  Map<String,Integer> factorValueMap=statisticsMap.get(cartridgeType);
  if (factorValueMap != null) {
    if (factorValueMap.containsKey(scalingFactor.toString())) {
      factorValueMap.remove(scalingFactor.toString());
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove statistics found for the cartridge type, scaling factor
 * @param cartridgeType
 * @param scalingFactor
 */
public void removeStatistics(String cartridgeType,MockScalingFactor scalingFactor){
  Map<String,Integer> factorValueMap=statisticsMap.get(cartridgeType);
  if (factorValueMap != null) {
    if (factorValueMap.containsKey(scalingFactor.toString())) {
      factorValueMap.remove(scalingFactor.toString());
    }
  }
}
Program: 115705
Project: 115705
Buggy source:
/** 
 * Add statistics value for a cartridge type, autoscaling factor
 * @param cartridgeType
 * @param scalingFactor
 * @param value
 */
public void addStatistics(String cartridgeType,MockScalingFactor scalingFactor,Integer value){
  Map<String,Integer> factorValueMap=statisticsMap.get(cartridgeType);
  if (factorValueMap == null) {
synchronized (MockHealthStatistics.class) {
      if (factorValueMap == null) {
        factorValueMap=new ConcurrentHashMap<String,Integer>();
        statisticsMap.put(cartridgeType,factorValueMap);
      }
    }
  }
  factorValueMap.put(scalingFactor.toString(),value);
}

Fixed version (ground truth):
/** 
 * Add statistics value for a cartridge type, scaling factor
 * @param cartridgeType
 * @param scalingFactor
 * @param value
 */
public void addStatistics(String cartridgeType,MockScalingFactor scalingFactor,Integer value){
  Map<String,Integer> factorValueMap=statisticsMap.get(cartridgeType);
  if (factorValueMap == null) {
synchronized (MockHealthStatistics.class) {
      if (factorValueMap == null) {
        factorValueMap=new ConcurrentHashMap<String,Integer>();
        statisticsMap.put(cartridgeType,factorValueMap);
      }
    }
  }
  factorValueMap.put(scalingFactor.toString(),value);
}
Program: 115707
Project: 115707
Buggy source:
@Override public Response handleRequest(Message message,ClassResourceInfo classResourceInfo){
  HttpHeaders headers=new HttpHeadersImpl(message);
  List<String> authHeader=headers.getRequestHeader(HttpHeaders.AUTHORIZATION);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + this.getClass());
  }
  if (!AuthenticationContext.isAthenticated() && authHeader != null && authHeader.size() > 0 && canHandle(authHeader.get(0).trim().split("String_Node_Str")[0])) {
    return handle(message,classResourceInfo);
  }
  return null;
}

Fixed version (ground truth):
@Override public Response handleRequest(Message message,ClassResourceInfo classResourceInfo){
  HttpHeaders headers=new HttpHeadersImpl(message);
  if (!StringUtils.isEmpty(headers.getRequestHeaders().getFirst(HttpHeaders.AUTHORIZATION))) {
    return handle(message,classResourceInfo);
  }
 else {
    return Response.status(Response.Status.FORBIDDEN).build();
  }
}
Program: 115708
Project: 115708
Buggy source:
@Override public Response handle(Message message,ClassResourceInfo classResourceInfo){
  try {
    HttpHeaders httpHeaders=new HttpHeadersImpl(message);
    String header=httpHeaders.getRequestHeaders().getFirst("String_Node_Str");
    if (header.startsWith(BEARER)) {
      String accessToken=header.substring(7).trim();
      boolean valid;
      String appId=extractAppIdFromIdToken(accessToken);
      String requestUrl=(String)message.get(Message.REQUEST_URI);
      String basePath=(String)message.get(Message.BASE_PATH);
      String requestedAppId=extractApplicationIdFromUrl(requestUrl,basePath);
      if (org.apache.commons.lang3.StringUtils.isEmpty(appId) || org.apache.commons.lang3.StringUtils.isEmpty(requestedAppId)) {
        valid=false;
      }
 else {
        valid=appId.equals(requestedAppId);
      }
      if (!valid) {
        return Response.status(Response.Status.FORBIDDEN).build();
      }
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Response.status(Response.Status.FORBIDDEN).build();
  }
  AuthenticationContext.setAuthenticated(true);
  return null;
}

Fixed version (ground truth):
@Override public Response handle(Message message,ClassResourceInfo classResourceInfo){
  try {
    HttpHeaders httpHeaders=new HttpHeadersImpl(message);
    String header=httpHeaders.getRequestHeaders().getFirst("String_Node_Str");
    if (header.startsWith(BEARER)) {
      String accessToken=header.substring(7).trim();
      boolean valid;
      String appId_in_token=extractAppIdFromIdToken(accessToken);
      String requestUrl=(String)message.get(Message.REQUEST_URI);
      String basePath=(String)message.get(Message.BASE_PATH);
      String requestedAppId=extractApplicationIdFromUrl(requestUrl,basePath);
      if (org.apache.commons.lang3.StringUtils.isEmpty(appId_in_token) || org.apache.commons.lang3.StringUtils.isEmpty(requestedAppId)) {
        valid=false;
      }
 else {
        valid=appId_in_token.equals(requestedAppId);
        if (!valid) {
          log.error("String_Node_Str" + appId_in_token + "String_Node_Str"+ requestedAppId);
        }
      }
      if (!valid) {
        return Response.status(Response.Status.FORBIDDEN).build();
      }
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    return Response.status(Response.Status.FORBIDDEN).build();
  }
  AuthenticationContext.setAuthenticated(true);
  return null;
}
Program: 115709
Project: 115709
Buggy source:
public void addPropertyToApplication(String applicationId,Property property) throws RegistryException {
  Registry registry=getRegistry();
  String resourcePath=mainResource + applicationId;
  try {
    PrivilegedCarbonContext ctx=PrivilegedCarbonContext.getThreadLocalCarbonContext();
    ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    Resource nodeResource=null;
    if (registry.resourceExists(resourcePath)) {
      nodeResource=registry.get(resourcePath);
    }
 else {
      nodeResource=registry.newResource();
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + nodeResource.getPath());
      }
    }
    for (    String value : property.getValues()) {
      nodeResource.addProperty(property.getKey(),value);
    }
    boolean updated=false;
    for (    String value : property.getValues()) {
      if (!propertyValueExist(nodeResource,property.getKey(),value)) {
        updated=true;
        log.info(String.format("String_Node_Str",resourcePath,property.getKey(),value));
        nodeResource.addProperty(property.getKey(),value);
      }
 else {
        log.info(String.format("String_Node_Str",property.getKey(),value));
      }
    }
    if (updated) {
      registry.put(resourcePath,nodeResource);
    }
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + resourcePath;
    log.error(msg,e);
    throw new RegistryException(msg,e);
  }
}

Fixed version (ground truth):
public void addPropertyToApplication(String applicationId,Property property) throws RegistryException {
  Registry registry=getRegistry();
  String resourcePath=mainResource + applicationId;
  try {
    PrivilegedCarbonContext ctx=PrivilegedCarbonContext.getThreadLocalCarbonContext();
    ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    Resource nodeResource=null;
    if (registry.resourceExists(resourcePath)) {
      nodeResource=registry.get(resourcePath);
    }
 else {
      nodeResource=registry.newResource();
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + nodeResource.getPath());
      }
    }
    boolean updated=false;
    for (    String value : property.getValues()) {
      if (!propertyValueExist(nodeResource,property.getKey(),value)) {
        updated=true;
        log.info(String.format("String_Node_Str",resourcePath,property.getKey(),value));
        nodeResource.addProperty(property.getKey(),value);
      }
 else {
        log.info(String.format("String_Node_Str",property.getKey(),value));
      }
    }
    if (updated) {
      registry.put(resourcePath,nodeResource);
    }
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + resourcePath;
    log.error(msg,e);
    throw new RegistryException(msg,e);
  }
}
Program: 115710
Project: 115710
Buggy source:
public int getMax(){
  return PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getNetworkPartitionByNetworkPartitionId(networkPartitionId).getPartition(partitionId).getPartitionMax();
}

Fixed version (ground truth):
public int getMax(){
  return PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getNetworkPartitionByNetworkPartitionId(networkPartitionId).getPartitionRef(partitionId).getPartitionMax();
}
Program: 115711
Project: 115711
Buggy source:
private void removeOldPartitionsFromClusterMonitor(ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext,NetworkPartitionRef networkPartition){
  for (  InstanceContext instanceContext : clusterLevelNetworkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
    ClusterInstanceContext clusterInstanceContext=(ClusterInstanceContext)instanceContext;
    for (    ClusterLevelPartitionContext clusterLevelPartitionContext : clusterInstanceContext.getPartitionCtxts()) {
      if (null == networkPartition.getPartition(clusterLevelPartitionContext.getPartitionId())) {
        clusterLevelPartitionContext.setIsObsoletePartition(true);
        Iterator<MemberContext> memberContextIterator=clusterLevelPartitionContext.getActiveMembers().iterator();
        while (memberContextIterator.hasNext()) {
          clusterLevelPartitionContext.moveActiveMemberToTerminationPendingMembers(memberContextIterator.next().getMemberId());
        }
        memberContextIterator=clusterLevelPartitionContext.getPendingMembers().iterator();
        while (memberContextIterator.hasNext()) {
          clusterLevelPartitionContext.movePendingMemberToObsoleteMembers(memberContextIterator.next().getMemberId());
        }
      }
    }
  }
}

Fixed version (ground truth):
private void removeOldPartitionsFromClusterMonitor(ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext,NetworkPartitionRef networkPartition){
  for (  InstanceContext instanceContext : clusterLevelNetworkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
    ClusterInstanceContext clusterInstanceContext=(ClusterInstanceContext)instanceContext;
    for (    ClusterLevelPartitionContext clusterLevelPartitionContext : clusterInstanceContext.getPartitionCtxts()) {
      if (null == networkPartition.getPartitionRef(clusterLevelPartitionContext.getPartitionId())) {
        clusterLevelPartitionContext.setIsObsoletePartition(true);
        Iterator<MemberContext> memberContextIterator=clusterLevelPartitionContext.getActiveMembers().iterator();
        while (memberContextIterator.hasNext()) {
          clusterLevelPartitionContext.moveActiveMemberToTerminationPendingMembers(memberContextIterator.next().getMemberId());
        }
        memberContextIterator=clusterLevelPartitionContext.getPendingMembers().iterator();
        while (memberContextIterator.hasNext()) {
          clusterLevelPartitionContext.movePendingMemberToObsoleteMembers(memberContextIterator.next().getMemberId());
        }
      }
    }
  }
}
Program: 115712
Project: 115712
Buggy source:
private static NetworkPartitionRef[] convertNetworkPartitionToASStubNetworkPartition(List<NetworkPartitionReferenceBean> networkPartitionReferenceBeans){
  List<NetworkPartitionRef> networkPartitionRefList=new ArrayList<NetworkPartitionRef>();
  for (  NetworkPartitionReferenceBean networkPartitionReferenceBean : networkPartitionReferenceBeans) {
    NetworkPartitionRef networkPartitionRef=new NetworkPartitionRef();
    networkPartitionRef.setId(networkPartitionReferenceBean.getId());
    networkPartitionRef.setPartitionAlgo(networkPartitionReferenceBean.getPartitionAlgo());
    networkPartitionRef.setPartitions(convertToASStubPartitions(networkPartitionReferenceBean.getPartitions()));
    networkPartitionRefList.add(networkPartitionRef);
  }
  return networkPartitionRefList.toArray(new NetworkPartitionRef[networkPartitionRefList.size()]);
}

Fixed version (ground truth):
private static NetworkPartitionRef[] convertNetworkPartitionToASStubNetworkPartition(List<NetworkPartitionReferenceBean> networkPartitionReferenceBeans){
  List<NetworkPartitionRef> networkPartitionRefList=new ArrayList<NetworkPartitionRef>();
  for (  NetworkPartitionReferenceBean networkPartitionReferenceBean : networkPartitionReferenceBeans) {
    NetworkPartitionRef networkPartitionRef=new NetworkPartitionRef();
    networkPartitionRef.setId(networkPartitionReferenceBean.getId());
    networkPartitionRef.setPartitionAlgo(networkPartitionReferenceBean.getPartitionAlgo());
    networkPartitionRef.setPartitionRefs(convertToASStubPartitions(networkPartitionReferenceBean.getPartitions()));
    networkPartitionRefList.add(networkPartitionRef);
  }
  return networkPartitionRefList.toArray(new NetworkPartitionRef[networkPartitionRefList.size()]);
}
Program: 115713
Project: 115713
Buggy source:
private static List<NetworkPartitionReferenceBean> convertASStubNetworkPartitionRefsToNetworkPartitions(NetworkPartitionRef[] networkPartitions){
  List<NetworkPartitionReferenceBean> networkPartitionBeans=new ArrayList<NetworkPartitionReferenceBean>();
  for (  NetworkPartitionRef networkPartition : networkPartitions) {
    NetworkPartitionReferenceBean networkPartitionReferenceBean=new NetworkPartitionReferenceBean();
    networkPartitionReferenceBean.setId(networkPartition.getId());
    networkPartitionReferenceBean.setPartitionAlgo(networkPartition.getPartitionAlgo());
    networkPartitionReferenceBean.setPartitions(convertASStubPartitionRefsToPartitionReferences(networkPartition.getPartitions()));
    networkPartitionBeans.add(networkPartitionReferenceBean);
  }
  return networkPartitionBeans;
}

Fixed version (ground truth):
private static List<NetworkPartitionReferenceBean> convertASStubNetworkPartitionRefsToNetworkPartitions(NetworkPartitionRef[] networkPartitions){
  List<NetworkPartitionReferenceBean> networkPartitionBeans=new ArrayList<NetworkPartitionReferenceBean>();
  for (  NetworkPartitionRef networkPartition : networkPartitions) {
    NetworkPartitionReferenceBean networkPartitionReferenceBean=new NetworkPartitionReferenceBean();
    networkPartitionReferenceBean.setId(networkPartition.getId());
    networkPartitionReferenceBean.setPartitionAlgo(networkPartition.getPartitionAlgo());
    networkPartitionReferenceBean.setPartitions(convertASStubPartitionRefsToPartitionReferences(networkPartition.getPartitionRefs()));
    networkPartitionBeans.add(networkPartitionReferenceBean);
  }
  return networkPartitionBeans;
}
Program: 115714
Project: 115714
Buggy source:
private static List<NetworkPartitionReferenceBean> convertASStubNetworkPartitionsToNetworkPartitionReferences(NetworkPartitionRef[] networkPartitions){
  List<NetworkPartitionReferenceBean> networkPartitionBeans=new ArrayList<NetworkPartitionReferenceBean>();
  for (  NetworkPartitionRef networkPartitionRef : networkPartitions) {
    NetworkPartitionReferenceBean networkPartitionReferenceBean=new NetworkPartitionReferenceBean();
    networkPartitionReferenceBean.setId(networkPartitionRef.getId());
    networkPartitionReferenceBean.setPartitions(convertASStubPartitionsToPartitions(networkPartitionRef.getPartitions()));
    networkPartitionBeans.add(networkPartitionReferenceBean);
  }
  return networkPartitionBeans;
}

Fixed version (ground truth):
private static List<NetworkPartitionReferenceBean> convertASStubNetworkPartitionsToNetworkPartitionReferences(NetworkPartitionRef[] networkPartitions){
  List<NetworkPartitionReferenceBean> networkPartitionBeans=new ArrayList<NetworkPartitionReferenceBean>();
  for (  NetworkPartitionRef networkPartitionRef : networkPartitions) {
    NetworkPartitionReferenceBean networkPartitionReferenceBean=new NetworkPartitionReferenceBean();
    networkPartitionReferenceBean.setId(networkPartitionRef.getId());
    networkPartitionReferenceBean.setPartitionAlgo(networkPartitionRef.getPartitionAlgo());
    networkPartitionReferenceBean.setPartitions(convertASStubPartitionsToPartitions(networkPartitionRef.getPartitionRefs()));
    networkPartitionBeans.add(networkPartitionReferenceBean);
  }
  return networkPartitionBeans;
}
Program: 115715
Project: 115715
Buggy source:
private static List<PartitionReferenceBean> convertASStubPartitionsToPartitions(PartitionRef[] partitions){
  List<PartitionReferenceBean> partitionBeans=new ArrayList<PartitionReferenceBean>();
  for (  PartitionRef partition : partitions) {
    PartitionReferenceBean partitionBean=new PartitionReferenceBean();
    partitionBean.setId(partition.getId());
    partitionBeans.add(partitionBean);
  }
  return partitionBeans;
}

Fixed version (ground truth):
private static List<PartitionReferenceBean> convertASStubPartitionsToPartitions(PartitionRef[] partitions){
  List<PartitionReferenceBean> partitionBeans=new ArrayList<PartitionReferenceBean>();
  for (  PartitionRef partition : partitions) {
    PartitionReferenceBean partitionBean=new PartitionReferenceBean();
    partitionBean.setId(partition.getId());
    partitionBean.setPartitionMax(partition.getPartitionMax());
    partitionBeans.add(partitionBean);
  }
  return partitionBeans;
}
Program: 115716
Project: 115716
Buggy source:
/** 
 * Find Cartridges In ServiceGroup
 * @param serviceGroup serviceGroup
 * @param cartridges List of cartridges
 */
private static void findCartridgesInServiceGroup(ServiceGroup serviceGroup,List<String> cartridges){
  if (serviceGroup == null || cartridges == null) {
    return;
  }
  if (serviceGroup.getCartridges() != null) {
    for (    String cartridge : serviceGroup.getCartridges()) {
      if (!cartridges.contains(cartridge)) {
        cartridges.add(cartridge);
      }
    }
  }
  if (serviceGroup.getGroups() != null) {
    for (    ServiceGroup seGroup : serviceGroup.getGroups()) {
      findCartridgesInServiceGroup(seGroup,cartridges);
    }
  }
}

Fixed version (ground truth):
/** 
 * Find Cartridges In ServiceGroup
 * @param serviceGroup serviceGroup
 * @param cartridges List of cartridges
 */
private static void findCartridgesInServiceGroup(ServiceGroup serviceGroup,List<String> cartridges){
  if (serviceGroup == null || cartridges == null) {
    return;
  }
  if (serviceGroup.getCartridges() != null) {
    for (    String cartridge : serviceGroup.getCartridges()) {
      if (!cartridges.contains(cartridge) & cartridge != null) {
        cartridges.add(cartridge);
      }
    }
  }
  if (serviceGroup.getGroups() != null) {
    for (    ServiceGroup seGroup : serviceGroup.getGroups()) {
      findCartridgesInServiceGroup(seGroup,cartridges);
    }
  }
}
Program: 115717
Project: 115717
Buggy source:
/** 
 * Find Cartridges In ServiceGroup
 * @param serviceGroup serviceGroup
 * @param cartridges List of cartridges
 */
private static void findCartridgesInServiceGroup(ServiceGroup serviceGroup,List<String> cartridges){
  if (serviceGroup == null || cartridges == null) {
    return;
  }
  if (serviceGroup.getCartridges() != null) {
    for (    String cartridge : serviceGroup.getCartridges()) {
      if (!cartridges.contains(cartridge)) {
        cartridges.add(cartridge);
      }
    }
  }
  if (serviceGroup.getGroups() != null) {
    for (    ServiceGroup seGroup : serviceGroup.getGroups()) {
      findCartridgesInServiceGroup(seGroup,cartridges);
    }
  }
}

Fixed version (ground truth):
/** 
 * Find Cartridges In ServiceGroup
 * @param serviceGroup serviceGroup
 * @param cartridges List of cartridges
 */
private static void findCartridgesInServiceGroup(ServiceGroup serviceGroup,List<String> cartridges){
  if (serviceGroup == null || cartridges == null) {
    return;
  }
  if (serviceGroup.getCartridges() != null) {
    for (    String cartridge : serviceGroup.getCartridges()) {
      if (!cartridges.contains(cartridge) & cartridge != null) {
        cartridges.add(cartridge);
      }
    }
  }
  if (serviceGroup.getGroups() != null) {
    for (    ServiceGroup seGroup : serviceGroup.getGroups()) {
      findCartridgesInServiceGroup(seGroup,cartridges);
    }
  }
}
Program: 115718
Project: 115718
Buggy source:
private String generateMemberId(String clusterId){
  UUID memberId=UUID.randomUUID();
  return clusterId + memberId.toString();
}

Fixed version (ground truth):
private String generateMemberId(String clusterId){
  UUID uuid=UUID.randomUUID();
  String memberId="String_Node_Str" + clusterId + uuid.toString();
  return memberId;
}
Program: 115719
Project: 115719
Buggy source:
private List<ApplicationChildContext> traverseGraphByLevel(List<ApplicationChildContext> contexts,ParentComponentMonitor parentMonitor,String instanceId){
  for (  ApplicationChildContext context : contexts) {
    Monitor monitor=parentMonitor.getMonitor(context.getId());
    if (monitor.getInstance(instanceId) == null || monitor.getInstancesByParentInstanceId(instanceId).isEmpty()) {
      return contexts;
    }
  }
  for (  ApplicationChildContext context : contexts) {
    return traverseGraphByLevel(context.getApplicationChildContextList(),parentMonitor,instanceId);
  }
  return null;
}

Fixed version (ground truth):
private List<ApplicationChildContext> traverseGraphByLevel(List<ApplicationChildContext> contexts,ParentComponentMonitor parentMonitor,String instanceId){
  for (  ApplicationChildContext context : contexts) {
    Monitor monitor=parentMonitor.getMonitor(context.getId());
    if (monitor.getInstance(instanceId) == null || monitor.getInstancesByParentInstanceId(instanceId).isEmpty()) {
      return contexts;
    }
  }
  for (  ApplicationChildContext context : contexts) {
    List<ApplicationChildContext> contexts1=traverseGraphByLevel(context.getApplicationChildContextList(),parentMonitor,instanceId);
    if (contexts1 != null && !contexts1.isEmpty()) {
      return contexts1;
    }
  }
  return null;
}
Program: 115720
Project: 115720
Buggy source:
private MemberContext createMemberContext(String applicationId,String cartridgeType,String memberId,LoadBalancingIPType loadBalancingIPType,InstanceContext instanceContext){
  MemberContext memberContext=new MemberContext(applicationId,cartridgeType,instanceContext.getClusterId(),memberId);
  memberContext.setClusterInstanceId(instanceContext.getClusterInstanceId());
  memberContext.setNetworkPartitionId(instanceContext.getNetworkPartitionId());
  memberContext.setPartition(instanceContext.getPartition());
  memberContext.setInitTime(instanceContext.getInitTime());
  memberContext.setProperties(instanceContext.getProperties());
  memberContext.setLoadBalancingIPType(loadBalancingIPType);
  memberContext.setInitTime(System.currentTimeMillis());
  memberContext.setObsoleteExpiryTime(instanceContext.getObsoleteExpiryTime());
  return memberContext;
}

Fixed version (ground truth):
private MemberContext createMemberContext(String applicationId,String cartridgeType,String memberId,LoadBalancingIPType loadBalancingIPType,InstanceContext instanceContext){
  MemberContext memberContext=new MemberContext(applicationId,cartridgeType,instanceContext.getClusterId(),memberId);
  memberContext.setClusterInstanceId(instanceContext.getClusterInstanceId());
  memberContext.setNetworkPartitionId(instanceContext.getNetworkPartitionId());
  memberContext.setPartition(cloudControllerContext.getNetworkPartition(instanceContext.getNetworkPartitionId()).getPartition(instanceContext.getPartition().getId()));
  memberContext.setInitTime(instanceContext.getInitTime());
  memberContext.setProperties(instanceContext.getProperties());
  memberContext.setLoadBalancingIPType(loadBalancingIPType);
  memberContext.setInitTime(System.currentTimeMillis());
  memberContext.setObsoleteExpiryTime(instanceContext.getObsoleteExpiryTime());
  return memberContext;
}
Program: 115722
Project: 115722
Buggy source:
/** 
 * Find the ApplicationContext using Breadth first search.
 * @param id       the alias/id of group/cluster
 * @param contexts the list of contexts in the same level of the tree
 * @return ApplicationContext of the given id
 */
private ApplicationChildContext getApplicationChildContextById(String id,List<ApplicationChildContext> contexts){
  for (  ApplicationChildContext context : contexts) {
    if (context.getId().equals(id)) {
      return context;
    }
  }
  for (  ApplicationChildContext context : contexts) {
    return getApplicationChildContextById(id,context.getApplicationChildContextList());
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Find the ApplicationContext using Breadth first search.
 * @param id       the alias/id of group/cluster
 * @param contexts the list of contexts in the same level of the tree
 * @return ApplicationContext of the given id
 */
private ApplicationChildContext getApplicationChildContextById(String id,List<ApplicationChildContext> contexts){
  for (  ApplicationChildContext context : contexts) {
    if (context.getId().equals(id)) {
      return context;
    }
  }
  for (  ApplicationChildContext context : contexts) {
    ApplicationChildContext childContext=getApplicationChildContextById(id,context.getApplicationChildContextList());
    if (childContext != null) {
      return childContext;
    }
  }
  return null;
}
Program: 115723
Project: 115723
Buggy source:
@Override public boolean process(String idOfComponent,String appId,String instanceId){
  boolean statusChanged;
  statusChanged=doProcess(idOfComponent,appId,instanceId);
  if (statusChanged) {
    return statusChanged;
  }
  if (nextProcessor != null) {
    return nextProcessor.process(idOfComponent,appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str",idOfComponent,instanceId));
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean process(String idOfComponent,String appId,String instanceId){
  boolean statusChanged;
  statusChanged=doProcess(idOfComponent,appId,instanceId);
  if (statusChanged) {
    return true;
  }
  if (nextProcessor != null) {
    return nextProcessor.process(idOfComponent,appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str",idOfComponent,instanceId));
  }
  return false;
}
Program: 115726
Project: 115726
Buggy source:
@Override public void initialize(){
  groupStatusActiveProcessor=new GroupStatusActiveProcessor();
  add(groupStatusActiveProcessor);
  groupStatusTerminatedProcessor=new GroupStatusTerminatedProcessor();
  add(groupStatusTerminatedProcessor);
  groupStatusTerminatingProcessor=new GroupStatusTerminatingProcessor();
  add(groupStatusTerminatingProcessor);
  groupStatusInactiveProcessor=new GroupStatusInactiveProcessor();
  add(groupStatusInactiveProcessor);
}

Fixed version (ground truth):
@Override public void initialize(){
  GroupStatusActiveProcessor groupStatusActiveProcessor=new GroupStatusActiveProcessor();
  add(groupStatusActiveProcessor);
  GroupStatusTerminatedProcessor groupStatusTerminatedProcessor=new GroupStatusTerminatedProcessor();
  add(groupStatusTerminatedProcessor);
  GroupStatusTerminatingProcessor groupStatusTerminatingProcessor=new GroupStatusTerminatingProcessor();
  add(groupStatusTerminatingProcessor);
  GroupStatusInactiveProcessor groupStatusInactiveProcessor=new GroupStatusInactiveProcessor();
  add(groupStatusInactiveProcessor);
}
Program: 115727
Project: 115727
Buggy source:
@Override public boolean process(String idOfComponent,String appId,String instanceId){
  boolean statusChanged;
  statusChanged=doProcess(idOfComponent,appId,instanceId);
  if (statusChanged) {
    return statusChanged;
  }
  if (nextProcessor != null) {
    return nextProcessor.process(idOfComponent,appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str",idOfComponent,instanceId));
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean process(String idOfComponent,String appId,String instanceId){
  boolean statusChanged;
  statusChanged=doProcess(idOfComponent,appId,instanceId);
  if (statusChanged) {
    return true;
  }
  if (nextProcessor != null) {
    return nextProcessor.process(idOfComponent,appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str",idOfComponent,instanceId));
  }
  return false;
}
Program: 115729
Project: 115729
Buggy source:
@Override public boolean process(String idOfComponent,String appId,String instanceId){
  boolean statusChanged;
  statusChanged=doProcess(idOfComponent,appId,instanceId);
  if (statusChanged) {
    return statusChanged;
  }
  if (nextProcessor != null) {
    return nextProcessor.process(idOfComponent,appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str",idOfComponent,instanceId));
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean process(String idOfComponent,String appId,String instanceId){
  boolean statusChanged;
  statusChanged=doProcess(idOfComponent,appId,instanceId);
  if (statusChanged) {
    return true;
  }
  if (nextProcessor != null) {
    return nextProcessor.process(idOfComponent,appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str",idOfComponent,instanceId));
  }
  return false;
}
Program: 115731
Project: 115731
Buggy source:
/** 
 * Gets all available cartridges.
 * @return 200 if cartridges exists, 404 if no cartridges found
 * @throws RestAPIException the rest api exception
 */
@GET @Path("String_Node_Str") @Produces("String_Node_Str") @Consumes("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response getCartridges() throws RestAPIException {
  List<CartridgeBean> cartridges=StratosApiV41Utils.getAvailableCartridges(null,false,getConfigContext());
  if (cartridges == null || cartridges.isEmpty()) {
    return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,"String_Node_Str")).build();
  }
  CartridgeBean[] cartridgeArray=cartridges.toArray(new CartridgeBean[cartridges.size()]);
  return Response.ok().entity(cartridgeArray).build();
}

Fixed version (ground truth):
/** 
 * Gets all available cartridges.
 * @return 200 if cartridges exists, 404 if no cartridges found
 * @throws RestAPIException the rest api exception
 */
@GET @Path("String_Node_Str") @Produces("String_Node_Str") @Consumes("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response getCartridges() throws RestAPIException {
  List<CartridgeBean> cartridges=StratosApiV41Utils.getAvailableCartridges(null,null,getConfigContext());
  if (cartridges == null || cartridges.isEmpty()) {
    return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,"String_Node_Str")).build();
  }
  CartridgeBean[] cartridgeArray=cartridges.toArray(new CartridgeBean[cartridges.size()]);
  return Response.ok().entity(cartridgeArray).build();
}
Program: 115733
Project: 115733
Buggy source:
private static void updateApplicationMonitor(String appId,ApplicationStatus status,String networkPartitionId,String instanceId){
  ApplicationMonitor applicationMonitor=AutoscalerContext.getInstance().getAppMonitor(appId);
  NetworkPartitionContext context=applicationMonitor.getNetworkPartitionContext(networkPartitionId);
  if (applicationMonitor != null) {
    if (status == ApplicationStatus.Active) {
      context.movePendingInstanceToActiveInstances(instanceId);
    }
 else     if (status == ApplicationStatus.Terminating) {
      applicationMonitor.setTerminating(true);
      if (context.getActiveInstance(instanceId) != null) {
        context.moveActiveInstanceToTerminationPendingInstances(instanceId);
      }
 else       if (context.getPendingInstance(instanceId) != null) {
        context.movePendingInstanceToTerminationPendingInstances(instanceId);
      }
    }
 else     if (status == ApplicationStatus.Terminated) {
      context.removeTerminationPendingInstance(instanceId);
    }
    applicationMonitor.setStatus(status,instanceId);
  }
 else {
    log.warn("String_Node_Str" + appId);
  }
}

Fixed version (ground truth):
private static void updateApplicationMonitor(String appId,ApplicationStatus status,String networkPartitionId,String instanceId){
  ApplicationMonitor applicationMonitor=AutoscalerContext.getInstance().getAppMonitor(appId);
  NetworkPartitionContext context=applicationMonitor.getNetworkPartitionContext(networkPartitionId);
  if (applicationMonitor != null) {
    if (status == ApplicationStatus.Active) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + instanceId + "String_Node_Str"+ appId);
      }
      context.movePendingInstanceToActiveInstances(instanceId);
    }
 else     if (status == ApplicationStatus.Terminating) {
      applicationMonitor.setTerminating(true);
      if (context.getActiveInstance(instanceId) != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + instanceId + "String_Node_Str"+ "String_Node_Str"+ appId);
        }
        context.moveActiveInstanceToTerminationPendingInstances(instanceId);
      }
 else       if (context.getPendingInstance(instanceId) != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + instanceId + "String_Node_Str"+ appId);
        }
        context.movePendingInstanceToTerminationPendingInstances(instanceId);
      }
    }
 else     if (status == ApplicationStatus.Terminated) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + instanceId + "String_Node_Str"+ appId);
      }
      context.removeTerminationPendingInstance(instanceId);
    }
    applicationMonitor.setStatus(status,instanceId);
  }
 else {
    log.warn("String_Node_Str" + appId);
  }
}
Program: 115734
Project: 115734
Buggy source:
private static void updateGroupMonitor(String appId,String groupId,GroupStatus status,String networkPartitionId,String instanceId,String parentInstanceId){
  GroupMonitor monitor=getGroupMonitor(appId,groupId);
  if (monitor != null) {
    NetworkPartitionContext context=monitor.getNetworkPartitionContext(networkPartitionId);
    if (status == GroupStatus.Active) {
      context.movePendingInstanceToActiveInstances(instanceId);
    }
 else     if (status == GroupStatus.Terminating) {
      if (context.getActiveInstance(instanceId) != null) {
        context.moveActiveInstanceToTerminationPendingInstances(instanceId);
      }
 else       if (context.getPendingInstance(instanceId) != null) {
        context.movePendingInstanceToTerminationPendingInstances(instanceId);
      }
    }
 else     if (status == GroupStatus.Terminated) {
      context.removeTerminationPendingInstance(instanceId);
    }
    monitor.setStatus(status,instanceId,parentInstanceId);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
}

Fixed version (ground truth):
private static void updateGroupMonitor(String appId,String groupId,GroupStatus status,String networkPartitionId,String instanceId,String parentInstanceId){
  GroupMonitor monitor=getGroupMonitor(appId,groupId);
  if (monitor != null) {
    NetworkPartitionContext context=monitor.getNetworkPartitionContext(networkPartitionId);
    if (status == GroupStatus.Active) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
      }
      context.movePendingInstanceToActiveInstances(instanceId);
    }
 else     if (status == GroupStatus.Terminating) {
      if (context.getActiveInstance(instanceId) != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + "String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
        }
        context.moveActiveInstanceToTerminationPendingInstances(instanceId);
      }
 else       if (context.getPendingInstance(instanceId) != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + "String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
        }
        context.movePendingInstanceToTerminationPendingInstances(instanceId);
      }
    }
 else     if (status == GroupStatus.Terminated) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + "String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
      }
      context.removeTerminationPendingInstance(instanceId);
    }
    monitor.setStatus(status,instanceId,parentInstanceId);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
}
Program: 115735
Project: 115735
Buggy source:
public AbstractClusterContext(String clusterId,String serviceId){
  this.clusterId=clusterId;
  this.serviceId=serviceId;
  clusterInstanceMap=new HashMap<String,ClusterInstance>();
}

Fixed version (ground truth):
public AbstractClusterContext(String clusterId,String serviceId){
  this.clusterId=clusterId;
  this.serviceId=serviceId;
  clusterInstanceMap=new ConcurrentHashMap<String,ClusterInstance>();
}
Program: 115736
Project: 115736
Buggy source:
/** 
 * Utility method to send the termination notification to group/cluster based on termination list
 * @param terminationList termination list of siblings
 * @param notifier        who notified
 * @param terminateAll    whether terminate-all or not
 * @param instanceId      instance id of the instance
 */
private void sendTerminatingEventOnNotification(List<ApplicationChildContext> terminationList,String notifier,boolean terminateAll,String instanceId){
  Monitor monitor;
  for (  ApplicationChildContext terminationContext : terminationList) {
    monitor=this.aliasToActiveChildMonitorsMap.get(terminationContext.getId());
    if (monitor != null) {
      if (monitor instanceof GroupMonitor) {
        if (terminateAll || !notifier.equals(monitor.getId())) {
          ApplicationBuilder.handleGroupTerminatingEvent(this.appId,terminationContext.getId(),instanceId);
        }
      }
 else {
        if (log.isInfoEnabled()) {
          log.info("String_Node_Str" + appId + "String_Node_Str"+ this.id+ "String_Node_Str"+ terminationContext.getId());
        }
        ClusterStatusEventPublisher.sendClusterStatusClusterTerminatingEvent(this.appId,((ClusterMonitor)monitor).getServiceId(),terminationContext.getId(),instanceId);
      }
    }
 else {
      log.warn("String_Node_Str" + terminationContext.getId() + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Utility method to send the termination notification to group/cluster based on termination list
 * @param terminationList termination list of siblings
 * @param notifier        who notified
 * @param terminateAll    whether terminate-all or not
 * @param instanceId      instance id of the instance
 */
private void sendTerminatingEventOnNotification(List<ApplicationChildContext> terminationList,String notifier,boolean terminateAll,String instanceId){
  Monitor monitor;
  for (  ApplicationChildContext terminationContext : terminationList) {
    monitor=this.aliasToActiveChildMonitorsMap.get(terminationContext.getId());
    if (monitor != null) {
      if (monitor instanceof GroupMonitor) {
        if (terminateAll || !notifier.equals(monitor.getId())) {
          ApplicationBuilder.handleGroupTerminatingEvent(this.appId,terminationContext.getId(),instanceId);
        }
      }
 else {
        if (log.isInfoEnabled()) {
          log.info("String_Node_Str" + appId + "String_Node_Str"+ this.id+ "String_Node_Str"+ terminationContext.getId());
        }
        ClusterStatusEventPublisher.sendClusterStatusClusterTerminatingEvent(this.appId,((ClusterMonitor)monitor).getServiceId(),terminationContext.getId(),instanceId);
      }
    }
 else {
      log.warn("String_Node_Str" + terminationContext.getId() + "String_Node_Str"+ appId+ "String_Node_Str");
    }
  }
}
Program: 115737
Project: 115737
Buggy source:
/** 
 * This will start the parallel dependencies at once from the top level by traversing to find the terminated dependencies. it will get invoked when starting a child instance on termination of a sub tree
 * @param instanceId instance id of the instance
 */
public void startDependencyOnTermination(String instanceId){
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependenciesByTermination(this,instanceId);
  for (  ApplicationChildContext context : applicationContexts) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + context.getId() + "String_Node_Str");
    }
    if (!this.aliasToActiveChildMonitorsMap.containsKey(context.getId())) {
      log.info(String.format("String_Node_Str",getAppId(),context.getId()));
      List<String> parentInstanceIds=new ArrayList<String>();
      parentInstanceIds.add(instanceId);
      startMonitor(this,context,parentInstanceIds);
    }
 else {
      Monitor monitor=aliasToActiveChildMonitorsMap.get(context.getId());
      monitor.createInstanceOnDemand(instanceId);
    }
  }
}

Fixed version (ground truth):
/** 
 * This will start the parallel dependencies at once from the top level by traversing to find the terminated dependencies. it will get invoked when starting a child instance on termination of a sub tree
 * @param instanceId instance id of the instance
 */
public void startDependencyOnTermination(String instanceId){
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependenciesByTermination(this,instanceId);
  for (  ApplicationChildContext context : applicationContexts) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + context.getId() + "String_Node_Str");
    }
    if (!this.aliasToActiveChildMonitorsMap.containsKey(context.getId())) {
      log.info(String.format("String_Node_Str" + "String_Node_Str",getAppId(),context.getId()));
      List<String> parentInstanceIds=new ArrayList<String>();
      parentInstanceIds.add(instanceId);
      startMonitor(this,context,parentInstanceIds);
    }
 else {
      Monitor monitor=aliasToActiveChildMonitorsMap.get(context.getId());
      monitor.createInstanceOnDemand(instanceId);
    }
  }
}