nus-yam/ex-repair huggingface dataset:
Program: 116138
Project: 116138
Buggy source:
/** 
 * To set the status of the application monitor
 * @param status the status
 */
public void setStatus(ApplicationStatus status,String instanceId){
  ((ApplicationInstance)this.instanceIdToInstanceMap.get(instanceId)).setStatus(status);
  try {
    MonitorStatusEventBuilder.notifyChildren(this,new ApplicationStatusEvent(status,appId,instanceId));
  }
 catch (  MonitorNotFoundException e) {
    log.error("String_Node_Str" + appId,e);
  }
}

Fixed version (ground truth):
/** 
 * To set the status of the application monitor
 * @param status the status
 */
public void setStatus(ApplicationStatus status,String instanceId){
  ApplicationInstance applicationInstance=(ApplicationInstance)this.instanceIdToInstanceMap.get(instanceId);
  if (applicationInstance == null) {
    log.warn("String_Node_Str" + instanceId + "String_Node_Str");
  }
 else {
    if (applicationInstance.getStatus() != status) {
      applicationInstance.setStatus(status);
    }
  }
  try {
    MonitorStatusEventBuilder.notifyChildren(this,new ApplicationStatusEvent(status,appId,instanceId));
  }
 catch (  MonitorNotFoundException e) {
    log.error("String_Node_Str" + appId,e);
  }
}
Program: 116139
Project: 116139
Buggy source:
/** 
 * Will set the status of the monitor based on Topology Group status/child status like scaling
 * @param status status of the group
 */
public void setStatus(GroupStatus status,String instanceId){
  if (status == GroupStatus.Inactive && !this.hasStartupDependents) {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ this.parent.getId());
    if (this.isGroupScalingEnabled()) {
      ApplicationHolder.acquireReadLock();
      try {
        Application application=ApplicationHolder.getApplications().getApplication(this.appId);
        if (application != null) {
          Group group=application.getGroupRecursively(this.id);
          if (group != null) {
            GroupInstance context=group.getInstanceContexts(instanceId);
            MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,context.getParentId());
          }
        }
      }
  finally {
        ApplicationHolder.releaseReadLock();
      }
    }
 else {
      MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,instanceId);
    }
  }
  try {
    MonitorStatusEventBuilder.notifyChildren(this,new GroupStatusEvent(status,this.id,instanceId));
  }
 catch (  MonitorNotFoundException e) {
    log.error("String_Node_Str" + this.id,e);
  }
}

Fixed version (ground truth):
/** 
 * Will set the status of the monitor based on Topology Group status/child status like scaling
 * @param status status of the group
 */
public void setStatus(GroupStatus status,String instanceId){
  GroupInstance groupInstance=(GroupInstance)this.instanceIdToInstanceMap.get(instanceId);
  if (groupInstance == null) {
    log.warn("String_Node_Str" + instanceId + "String_Node_Str");
  }
 else {
    if (groupInstance.getStatus() != status) {
      groupInstance.setStatus(status);
    }
  }
  if (status == GroupStatus.Inactive && !this.hasStartupDependents) {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    log.info("String_Node_Str" + this.id + "String_Node_Str"+ this.parent.getId());
    if (this.isGroupScalingEnabled()) {
      ApplicationHolder.acquireReadLock();
      try {
        Application application=ApplicationHolder.getApplications().getApplication(this.appId);
        if (application != null) {
          Group group=application.getGroupRecursively(this.id);
          if (group != null) {
            GroupInstance context=group.getInstanceContexts(instanceId);
            MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,context.getParentId());
          }
        }
      }
  finally {
        ApplicationHolder.releaseReadLock();
      }
    }
 else {
      MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent,status,this.id,instanceId);
    }
  }
  try {
    MonitorStatusEventBuilder.notifyChildren(this,new GroupStatusEvent(status,this.id,instanceId));
  }
 catch (  MonitorNotFoundException e) {
    log.error("String_Node_Str" + this.id,e);
  }
}
Program: 116140
Project: 116140
Buggy source:
private void addMembersFromTopology(Cluster cluster,org.apache.stratos.cloud.controller.stub.domain.Partition partition,ClusterLevelPartitionContext clusterLevelPartitionContext){
  for (  Member member : cluster.getMembers()) {
    String memberId=member.getMemberId();
    if (member.getPartitionId().equalsIgnoreCase(partition.getId())) {
      MemberContext memberContext=new MemberContext();
      memberContext.setClusterId(member.getClusterId());
      memberContext.setMemberId(memberId);
      memberContext.setInitTime(member.getInitTime());
      memberContext.setPartition(partition);
      if (MemberStatus.Activated.equals(member.getStatus())) {
        if (log.isDebugEnabled()) {
          String msg=String.format("String_Node_Str",member.toString());
          log.debug(msg);
        }
        clusterLevelPartitionContext.addActiveMember(memberContext);
      }
 else       if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) {
        if (log.isDebugEnabled()) {
          String msg=String.format("String_Node_Str",member.toString());
          log.debug(msg);
        }
        clusterLevelPartitionContext.addPendingMember(memberContext);
      }
 else       if (MemberStatus.Suspended.equals(member.getStatus())) {
      }
      clusterLevelPartitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
      if (log.isInfoEnabled()) {
        log.info(String.format("String_Node_Str",memberId));
      }
    }
  }
}

Fixed version (ground truth):
private void addMembersFromTopology(Cluster cluster,org.apache.stratos.cloud.controller.stub.domain.Partition partition,ClusterLevelPartitionContext clusterLevelPartitionContext){
  for (  Member member : cluster.getMembers()) {
    String memberId=member.getMemberId();
    if (member.getPartitionId().equalsIgnoreCase(partition.getId())) {
      MemberContext memberContext=new MemberContext();
      memberContext.setClusterId(member.getClusterId());
      memberContext.setMemberId(memberId);
      memberContext.setInitTime(member.getInitTime());
      memberContext.setPartition(partition);
      memberContext.setProperties(AutoscalerUtil.toStubProperties(member.getProperties()));
      if (MemberStatus.Activated.equals(member.getStatus())) {
        clusterLevelPartitionContext.addActiveMember(memberContext);
        if (log.isDebugEnabled()) {
          String msg=String.format("String_Node_Str",member.toString());
          log.debug(msg);
        }
      }
 else       if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) {
        clusterLevelPartitionContext.addPendingMember(memberContext);
        if (log.isDebugEnabled()) {
          String msg=String.format("String_Node_Str",member.toString());
          log.debug(msg);
        }
      }
      clusterLevelPartitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
      if (log.isInfoEnabled()) {
        log.info(String.format("String_Node_Str",memberId));
      }
    }
  }
}
Program: 116141
Project: 116141
Buggy source:
public static org.apache.stratos.cloud.controller.stub.Properties toStubProperties(org.apache.stratos.common.Properties properties){
  org.apache.stratos.cloud.controller.stub.Properties stubProps=new org.apache.stratos.cloud.controller.stub.Properties();
  if (properties != null && properties.getProperties() != null) {
    for (    Property property : properties.getProperties()) {
      if ((property != null) && (property.getValue() != null)) {
        org.apache.stratos.cloud.controller.stub.Property newProperty=new org.apache.stratos.cloud.controller.stub.Property();
        newProperty.setName(property.getName());
        newProperty.setValue(property.getValue());
        stubProps.addProperties(newProperty);
      }
    }
  }
  return stubProps;
}

Fixed version (ground truth):
public static org.apache.stratos.cloud.controller.stub.Properties toStubProperties(java.util.Properties properties){
  org.apache.stratos.cloud.controller.stub.Properties stubProperties=new org.apache.stratos.cloud.controller.stub.Properties();
  if (properties != null) {
    for (    Map.Entry<Object,Object> entry : properties.entrySet()) {
      org.apache.stratos.cloud.controller.stub.Property newProperty=new org.apache.stratos.cloud.controller.stub.Property();
      newProperty.setName(entry.getKey().toString());
      newProperty.setValue(entry.getValue().toString());
      stubProperties.addProperties(newProperty);
    }
  }
  return stubProperties;
}
Program: 116142
Project: 116142
Buggy source:
private void updateContextFromRegistry(){
  if ((!isClustered()) || (isCoordinator())) {
    try {
      Object obj=RegistryManager.getInstance().read(CloudControllerConstants.DATA_RESOURCE);
      if (obj != null) {
        Object dataObj=Deserializer.deserializeFromByteArray((byte[])obj);
        if (dataObj instanceof CloudControllerContext) {
          CloudControllerContext serializedObj=(CloudControllerContext)dataObj;
          copyMap(serializedObj.kubernetesGroupsMap,kubernetesGroupsMap);
          copyMap(serializedObj.clusterIdToMemberContextListMap,clusterIdToMemberContextListMap);
          copyMap(serializedObj.memberIdToMemberContextMap,memberIdToMemberContextMap);
          copyMap(serializedObj.kubClusterIdToKubClusterContextMap,kubClusterIdToKubClusterContextMap);
          copyMap(serializedObj.clusterIdToContextMap,clusterIdToContextMap);
          copyMap(serializedObj.cartridgeTypeToPartitionIdsMap,cartridgeTypeToPartitionIdsMap);
          copyMap(serializedObj.cartridgeTypeToCartridgeMap,cartridgeTypeToCartridgeMap);
          copyMap(serializedObj.serviceGroupNameToServiceGroupMap,serviceGroupNameToServiceGroupMap);
          if (log.isDebugEnabled()) {
            log.debug("String_Node_Str");
          }
        }
 else {
          if (log.isDebugEnabled()) {
            log.debug("String_Node_Str");
          }
        }
      }
    }
 catch (    Exception e) {
      String msg="String_Node_Str" + "String_Node_Str";
      log.warn(msg,e);
    }
  }
}

Fixed version (ground truth):
private void updateContextFromRegistry(){
  if ((!isClustered()) || (isCoordinator())) {
    try {
      Object dataObj=RegistryManager.getInstance().read(CloudControllerConstants.DATA_RESOURCE);
      if (dataObj != null) {
        if (dataObj instanceof CloudControllerContext) {
          CloudControllerContext serializedObj=(CloudControllerContext)dataObj;
          copyMap(serializedObj.kubernetesGroupsMap,kubernetesGroupsMap);
          copyMap(serializedObj.clusterIdToMemberContextListMap,clusterIdToMemberContextListMap);
          copyMap(serializedObj.memberIdToMemberContextMap,memberIdToMemberContextMap);
          copyMap(serializedObj.kubClusterIdToKubClusterContextMap,kubClusterIdToKubClusterContextMap);
          copyMap(serializedObj.clusterIdToContextMap,clusterIdToContextMap);
          copyMap(serializedObj.cartridgeTypeToPartitionIdsMap,cartridgeTypeToPartitionIdsMap);
          copyMap(serializedObj.cartridgeTypeToCartridgeMap,cartridgeTypeToCartridgeMap);
          copyMap(serializedObj.serviceGroupNameToServiceGroupMap,serviceGroupNameToServiceGroupMap);
          if (log.isDebugEnabled()) {
            log.debug("String_Node_Str");
          }
        }
 else {
          if (log.isDebugEnabled()) {
            log.debug("String_Node_Str");
          }
        }
      }
    }
 catch (    Exception e) {
      String msg="String_Node_Str" + "String_Node_Str";
      log.warn(msg,e);
    }
  }
}
Program: 116143
Project: 116143
Buggy source:
public synchronized Object read(String resourcePath){
  try {
    Registry registry=ServiceReferenceHolder.getInstance().getRegistry();
    if (registry == null) {
      return null;
    }
    PrivilegedCarbonContext ctx=PrivilegedCarbonContext.getThreadLocalCarbonContext();
    ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    Resource resource=registry.get(CloudControllerConstants.CLOUD_CONTROLLER_RESOURCE + resourcePath);
    return resource.getContent();
  }
 catch (  ResourceNotFoundException ignore) {
    return null;
  }
catch (  RegistryException e) {
    String msg="String_Node_Str" + CloudControllerConstants.CLOUD_CONTROLLER_RESOURCE + resourcePath;
    log.error(msg,e);
    throw new CloudControllerException(msg,e);
  }
}

Fixed version (ground truth):
public synchronized Object read(String resourcePath){
  try {
    Registry registry=ServiceReferenceHolder.getInstance().getRegistry();
    if (registry == null) {
      return null;
    }
    PrivilegedCarbonContext ctx=PrivilegedCarbonContext.getThreadLocalCarbonContext();
    ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    Resource resource=registry.get(CloudControllerConstants.CLOUD_CONTROLLER_RESOURCE + resourcePath);
    Object content=resource.getContent();
    if (content != null) {
      try {
        return Deserializer.deserializeFromByteArray((byte[])content);
      }
 catch (      Exception e) {
        log.error("String_Node_Str",e);
        throw new RuntimeException(e);
      }
    }
    return null;
  }
 catch (  ResourceNotFoundException ignore) {
    return null;
  }
catch (  RegistryException e) {
    String msg="String_Node_Str" + CloudControllerConstants.CLOUD_CONTROLLER_RESOURCE + resourcePath;
    log.error(msg,e);
    throw new CloudControllerException(msg,e);
  }
}
Program: 116144
Project: 116144
Buggy source:
public static Topology retrieveTopology(){
  Object obj=RegistryManager.getInstance().read(CloudControllerConstants.TOPOLOGY_RESOURCE);
  if (obj != null) {
    try {
      Object dataObj=Deserializer.deserializeFromByteArray((byte[])obj);
      if (dataObj instanceof Topology) {
        return (Topology)dataObj;
      }
 else {
        return null;
      }
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.warn(msg,e);
    }
  }
  return null;
}

Fixed version (ground truth):
public static Topology retrieveTopology(){
  Object dataObj=RegistryManager.getInstance().read(CloudControllerConstants.TOPOLOGY_RESOURCE);
  if (dataObj != null) {
    try {
      if (dataObj instanceof Topology) {
        return (Topology)dataObj;
      }
 else {
        return null;
      }
    }
 catch (    Exception e) {
      String msg="String_Node_Str";
      log.warn(msg,e);
    }
  }
  return null;
}
Program: 116145
Project: 116145
Buggy source:
/** 
 * Get kill behaviour related to a Group
 * @param serviceGroupName Group name
 * @return String indicating the kill behavior
 * @throws ApplicationDefinitionException if an error occurs
 */
private String getKillbehaviour(String serviceGroupName) throws ApplicationDefinitionException {
}

Fixed version (ground truth):
/** 
 * Get kill behaviour related to a Group
 * @param serviceGroupName Group name
 * @return String indicating the kill behavior
 * @throws ApplicationDefinitionException if an error occurs
 */
private String getKillbehaviour(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
}
Program: 116146
Project: 116146
Buggy source:
/** 
 * Parse Group information
 * @param appId Application id
 * @param tenantId tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupCtxts  Group information
 * @param subscribableInformation Subscribable Information
 * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
 * @return Map [alias -> Group]
 * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
 */
private Map<String,Group> parseGroups(String appId,int tenantId,String key,List<GroupContext> groupCtxts,Map<String,SubscribableInfoContext> subscribableInformation,Map<String,GroupContext> definedGroupCtxts) throws ApplicationDefinitionException {
  Map<String,Group> groupAliasToGroup=new HashMap<String,Group>();
  for (  GroupContext groupCtxt : groupCtxts) {
    Group group=parseGroup(appId,tenantId,key,groupCtxt,subscribableInformation,definedGroupCtxts);
    groupAliasToGroup.put(group.getAlias(),group);
  }
  Set<Group> nestedGroups=new HashSet<Group>();
  getNestedGroupContexts(nestedGroups,groupAliasToGroup.values());
  filterDuplicatedGroupContexts(groupAliasToGroup.values(),nestedGroups);
  return groupAliasToGroup;
}

Fixed version (ground truth):
/** 
 * Parse Group information
 * @param appId Application id
 * @param tenantId tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupCtxts  Group information
 * @param subscribableInformation Subscribable Information
 * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
 * @return Map [alias -> Group]
 * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
 */
private Map<String,Group> parseGroups(String appId,int tenantId,String key,List<GroupContext> groupCtxts,Map<String,SubscribableInfoContext> subscribableInformation,Map<String,GroupContext> definedGroupCtxts) throws ApplicationDefinitionException {
  Map<String,Group> groupAliasToGroup=new HashMap<String,Group>();
  for (  GroupContext groupCtxt : groupCtxts) {
    ServiceGroup serviceGroup=getServiceGroup(groupCtxt.getName());
    Group group=parseGroup(appId,tenantId,key,groupCtxt,subscribableInformation,definedGroupCtxts,serviceGroup);
    groupAliasToGroup.put(group.getAlias(),group);
  }
  Set<Group> nestedGroups=new HashSet<Group>();
  getNestedGroupContexts(nestedGroups,groupAliasToGroup.values());
  filterDuplicatedGroupContexts(groupAliasToGroup.values(),nestedGroups);
  return groupAliasToGroup;
}
Program: 116147
Project: 116147
Buggy source:
/** 
 * Checks if group scaling is enabled for Service Group with name serviceGroupName
 * @param serviceGroupName name of the Service Group
 * @return true if group scaling is enabled, else false
 * @throws ApplicationDefinitionException if no Service Group found for the given serviceGroupName
 */
private boolean isGroupScalingEnabled(String serviceGroupName) throws ApplicationDefinitionException {
  ServiceGroup serviceGroup=getServiceGroup(serviceGroupName);
  if (serviceGroup == null) {
    handleError("String_Node_Str" + serviceGroupName);
  }
  return serviceGroup.isGroupscalingEnabled();
}

Fixed version (ground truth):
/** 
 * Checks if group scaling is enabled for Service Group with name serviceGroupName
 * @param serviceGroupName name of the Service Group
 * @return true if group scaling is enabled, else false
 * @throws ApplicationDefinitionException if no Service Group found for the given serviceGroupName
 */
private boolean isGroupScalingEnabled(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
  ServiceGroup nestedGroup=getNestedServiceGroup(serviceGroupName,serviceGroup);
  if (nestedGroup == null) {
    handleError("String_Node_Str" + serviceGroupName);
  }
  return nestedGroup.isGroupscalingEnabled();
}
Program: 116149
Project: 116149
Buggy source:
/** 
 * Find the startup order
 * @param groupContext GroupContext with Group defintion information
 * @return Set of Startup Orders which are defined in the Group
 * @throws ApplicationDefinitionException
 */
private String[] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException {
}

Fixed version (ground truth):
/** 
 * Find the startup order
 * @param groupContext GroupContext with Group defintion information
 * @return Set of Startup Orders which are defined in the Group
 * @throws ApplicationDefinitionException
 */
private String[] getStartupOrderForGroup(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
}
Program: 116150
Project: 116150
Buggy source:
/** 
 * @param childId
 */
protected void onChildInactiveEvent(String childId,String instanceId){
  List<ApplicationChildContext> terminationList;
  Monitor monitor;
  terminationList=this.startupDependencyTree.getTerminationDependencies(childId);
  ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
  if (this.startupDependencyTree.getTerminationBehavior() == DependencyTree.TerminationBehavior.TERMINATE_ALL && terminationList.size() == this.aliasToActiveMonitorsMap.size()) {
    if (this.parent != null) {
      ApplicationBuilder.handleGroupTerminatingEvent(this.appId,childId,instanceId);
    }
 else {
      sendTerminatingEventOnNotification(terminationList,childId,true,instanceId);
    }
    log.info("String_Node_Str" + childId + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    sendTerminatingEventOnNotification(terminationList,childId,false,instanceId);
  }
}

Fixed version (ground truth):
/** 
 * @param childId
 */
protected void onChildInactiveEvent(String childId,String instanceId){
  List<ApplicationChildContext> terminationList;
  Monitor monitor;
  terminationList=this.startupDependencyTree.getTerminationDependencies(childId);
  ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
  if (this.startupDependencyTree.getTerminationBehavior() == DependencyTree.TerminationBehavior.TERMINATE_ALL && terminationList.size() == this.aliasToActiveMonitorsMap.size()) {
    if (this.parent != null) {
      ApplicationBuilder.handleGroupTerminatingEvent(this.appId,this.id,instanceId);
    }
 else {
      sendTerminatingEventOnNotification(terminationList,childId,true,instanceId);
    }
    log.info("String_Node_Str" + childId + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    sendTerminatingEventOnNotification(terminationList,childId,false,instanceId);
  }
}
Program: 116151
Project: 116151
Buggy source:
/** 
 * @param childId
 */
protected void onChildInactiveEvent(String childId,String instanceId){
  List<ApplicationChildContext> terminationList;
  Monitor monitor;
  terminationList=this.startupDependencyTree.getTerminationDependencies(childId);
  ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
  if (this.startupDependencyTree.getTerminationBehavior() == DependencyTree.TerminationBehavior.TERMINATE_ALL && terminationList.size() == this.aliasToActiveMonitorsMap.size()) {
    if (this.parent != null) {
      ApplicationBuilder.handleGroupTerminatingEvent(this.appId,childId,instanceId);
    }
 else {
      sendTerminatingEventOnNotification(terminationList,childId,true,instanceId);
    }
    log.info("String_Node_Str" + childId + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    sendTerminatingEventOnNotification(terminationList,childId,false,instanceId);
  }
}

Fixed version (ground truth):
/** 
 * @param childId
 */
protected void onChildInactiveEvent(String childId,String instanceId){
  List<ApplicationChildContext> terminationList;
  Monitor monitor;
  terminationList=this.startupDependencyTree.getTerminationDependencies(childId);
  ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
  if (this.startupDependencyTree.getTerminationBehavior() == DependencyTree.TerminationBehavior.TERMINATE_ALL && terminationList.size() == this.aliasToActiveMonitorsMap.size()) {
    if (this.parent != null) {
      ApplicationBuilder.handleGroupTerminatingEvent(this.appId,this.id,instanceId);
    }
 else {
      sendTerminatingEventOnNotification(terminationList,childId,true,instanceId);
    }
    log.info("String_Node_Str" + childId + "String_Node_Str"+ "String_Node_Str");
  }
 else {
    sendTerminatingEventOnNotification(terminationList,childId,false,instanceId);
  }
}
Program: 116154
Project: 116154
Buggy source:
public GroupLevelPartitionContext(int max,String partitionId,String networkPartitionIid){
  super(max,partitionId,networkPartitionIid);
  this.pendingInstances=new ArrayList<Instance>();
  this.activeInstances=new ArrayList<Instance>();
  this.terminationPendingInstances=new ArrayList<Instance>();
  this.obsoletedInstances=new ConcurrentHashMap<String,Instance>();
  instanceStatsContexts=new ConcurrentHashMap<String,MemberStatsContext>();
  terminationPendingStartedTime=new HashMap<String,Long>();
  XMLConfiguration conf=ConfUtil.getInstance(null).getConfiguration();
  pendingInstanceExpiryTime=conf.getLong(StratosConstants.PENDING_VM_MEMBER_EXPIRY_TIMEOUT,900000);
  obsoltedInstanceExpiryTime=conf.getLong(StratosConstants.OBSOLETED_VM_MEMBER_EXPIRY_TIMEOUT,86400000);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + pendingInstanceExpiryTime);
    log.debug("String_Node_Str" + obsoltedInstanceExpiryTime);
  }
}

Fixed version (ground truth):
public GroupLevelPartitionContext(String partitionId,String networkPartitionIid){
  super(partitionId,networkPartitionIid);
  this.pendingInstances=new ArrayList<Instance>();
  this.activeInstances=new ArrayList<Instance>();
  this.terminationPendingInstances=new ArrayList<Instance>();
  this.obsoletedInstances=new ConcurrentHashMap<String,Instance>();
  instanceStatsContexts=new ConcurrentHashMap<String,MemberStatsContext>();
  terminationPendingStartedTime=new HashMap<String,Long>();
  XMLConfiguration conf=ConfUtil.getInstance(null).getConfiguration();
  pendingInstanceExpiryTime=conf.getLong(StratosConstants.PENDING_VM_MEMBER_EXPIRY_TIMEOUT,900000);
  obsoltedInstanceExpiryTime=conf.getLong(StratosConstants.OBSOLETED_VM_MEMBER_EXPIRY_TIMEOUT,86400000);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + pendingInstanceExpiryTime);
    log.debug("String_Node_Str" + obsoltedInstanceExpiryTime);
  }
}
Program: 116155
Project: 116155
Buggy source:
public PartitionContext(int max,String partitionId,String networkPartitionId){
  this.max=max;
  this.partitionId=partitionId;
  this.networkPartitionId=networkPartitionId;
}

Fixed version (ground truth):
public PartitionContext(String partitionId,String networkPartitionId){
  this.partitionId=partitionId;
  this.networkPartitionId=networkPartitionId;
}
Program: 116157
Project: 116157
Buggy source:
private ClusterDataHolder getClusterDataByAlias(String alias,Collection<Group> groups){
  for (  Group group : groups) {
    if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) {
      if (group.getClusterData(alias) != null) {
        return group.getClusterData(alias);
      }
    }
 else {
      if (group.getGroups() != null) {
        return getClusterDataByAlias(alias,group.getGroups());
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private ClusterDataHolder getClusterDataByAlias(String alias,Collection<Group> groups){
  for (  Group group : groups) {
    if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) {
      if (group.getClusterData(alias) != null) {
        return group.getClusterData(alias);
      }
    }
  }
  for (  Group group : groups) {
    if (group.getGroups() != null) {
      return getClusterDataByAlias(alias,group.getGroups());
    }
  }
  return null;
}
Program: 116159
Project: 116159
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 start a child monitor on termination of a sub tree
 */
public void startDependencyOnTermination() throws TopologyInConsistentException {
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependenciesByTermination();
}

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 start a child monitor on termination of a sub tree
 */
public void startDependencyOnTermination(String parentInstanceId) throws TopologyInConsistentException {
}
Program: 116160
Project: 116160
Buggy source:
/** 
 * Act upon one of its children got terminated
 * @param eventId id of the notifier
 */
protected void onChildTerminatedEvent(String eventId,String instanceId){
  List<ApplicationChildContext> terminationList;
  boolean allDependentTerminated=false;
  ApplicationChildContext context=this.startupDependencyTree.findApplicationContextWithIdInPrimaryTree(eventId);
  context.setTerminated(true);
  terminationList=this.startupDependencyTree.getTerminationDependencies(eventId);
  if (terminationList != null) {
    allDependentTerminated=allDependentTerminated(terminationList);
  }
  List<ApplicationChildContext> parentContexts=this.startupDependencyTree.findAllParentContextWithId(eventId);
  boolean parentsTerminated=false;
  boolean allParentsActive=false;
  if (parentContexts != null) {
    parentsTerminated=allParentTerminated(parentContexts,instanceId);
    allParentsActive=allParentActive(parentContexts,instanceId);
  }
  if ((terminationList.isEmpty() || allDependentTerminated) && (parentContexts.isEmpty() || parentsTerminated || allParentsActive)) {
    try {
      this.startDependencyOnTermination();
    }
 catch (    TopologyInConsistentException e) {
      log.error("String_Node_Str" + e);
    }
  }
 else {
    ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
    log.info("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Act upon one of its children got terminated
 * @param eventId id of the notifier
 */
protected void onChildTerminatedEvent(String eventId,String instanceId){
  List<ApplicationChildContext> terminationList;
  boolean allDependentTerminated=false;
  ApplicationChildContext context=this.startupDependencyTree.findApplicationContextWithIdInPrimaryTree(eventId);
  context.setTerminated(true);
  terminationList=this.startupDependencyTree.getTerminationDependencies(eventId);
  if (terminationList != null) {
    allDependentTerminated=allDependentTerminated(terminationList);
  }
  List<ApplicationChildContext> parentContexts=this.startupDependencyTree.findAllParentContextWithId(eventId);
  boolean parentsTerminated=false;
  boolean allParentsActive=false;
  if (parentContexts != null) {
    parentsTerminated=allParentTerminated(parentContexts,instanceId);
    allParentsActive=allParentActive(parentContexts,instanceId);
  }
  if ((terminationList.isEmpty() || allDependentTerminated) && (parentContexts.isEmpty() || parentsTerminated || allParentsActive)) {
    try {
      this.startDependencyOnTermination(parentInstanceId);
    }
 catch (    TopologyInConsistentException e) {
      log.error("String_Node_Str" + e);
    }
  }
 else {
    ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
    log.info("String_Node_Str");
  }
}
Program: 116161
Project: 116161
Buggy source:
/** 
 * Get kill behaviour related to a Group
 * @param serviceGroupName Group name
 * @return String indicating the kill behavior
 * @throws ApplicationDefinitionException if an error occurs
 */
private String getKillbehaviour(String serviceGroupName) throws ApplicationDefinitionException {
}

Fixed version (ground truth):
/** 
 * Get kill behaviour related to a Group
 * @param serviceGroupName Group name
 * @return String indicating the kill behavior
 * @throws ApplicationDefinitionException if an error occurs
 */
private String getKillbehaviour(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
}
Program: 116162
Project: 116162
Buggy source:
/** 
 * Parse Group information
 * @param appId Application id
 * @param tenantId tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupCtxts  Group information
 * @param subscribableInformation Subscribable Information
 * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
 * @return Map [alias -> Group]
 * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
 */
private Map<String,Group> parseGroups(String appId,int tenantId,String key,List<GroupContext> groupCtxts,Map<String,SubscribableInfoContext> subscribableInformation,Map<String,GroupContext> definedGroupCtxts) throws ApplicationDefinitionException {
  Map<String,Group> groupAliasToGroup=new HashMap<String,Group>();
  for (  GroupContext groupCtxt : groupCtxts) {
    Group group=parseGroup(appId,tenantId,key,groupCtxt,subscribableInformation,definedGroupCtxts);
    groupAliasToGroup.put(group.getAlias(),group);
  }
  Set<Group> nestedGroups=new HashSet<Group>();
  getNestedGroupContexts(nestedGroups,groupAliasToGroup.values());
  filterDuplicatedGroupContexts(groupAliasToGroup.values(),nestedGroups);
  return groupAliasToGroup;
}

Fixed version (ground truth):
/** 
 * Parse Group information
 * @param appId Application id
 * @param tenantId tenant id of tenant which deployed the Application
 * @param key Generated key for the Application
 * @param groupCtxts  Group information
 * @param subscribableInformation Subscribable Information
 * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information
 * @return Map [alias -> Group]
 * @throws ApplicationDefinitionException if an error occurs in parsing Group Information
 */
private Map<String,Group> parseGroups(String appId,int tenantId,String key,List<GroupContext> groupCtxts,Map<String,SubscribableInfoContext> subscribableInformation,Map<String,GroupContext> definedGroupCtxts) throws ApplicationDefinitionException {
  Map<String,Group> groupAliasToGroup=new HashMap<String,Group>();
  for (  GroupContext groupCtxt : groupCtxts) {
    ServiceGroup serviceGroup=getServiceGroup(groupCtxt.getName());
    Group group=parseGroup(appId,tenantId,key,groupCtxt,subscribableInformation,definedGroupCtxts,serviceGroup);
    groupAliasToGroup.put(group.getAlias(),group);
  }
  Set<Group> nestedGroups=new HashSet<Group>();
  getNestedGroupContexts(nestedGroups,groupAliasToGroup.values());
  filterDuplicatedGroupContexts(groupAliasToGroup.values(),nestedGroups);
  return groupAliasToGroup;
}
Program: 116163
Project: 116163
Buggy source:
/** 
 * Checks if group scaling is enabled for Service Group with name serviceGroupName
 * @param serviceGroupName name of the Service Group
 * @return true if group scaling is enabled, else false
 * @throws ApplicationDefinitionException if no Service Group found for the given serviceGroupName
 */
private boolean isGroupScalingEnabled(String serviceGroupName) throws ApplicationDefinitionException {
  ServiceGroup serviceGroup=getServiceGroup(serviceGroupName);
  if (serviceGroup == null) {
    handleError("String_Node_Str" + serviceGroupName);
  }
  return serviceGroup.isGroupscalingEnabled();
}

Fixed version (ground truth):
/** 
 * Checks if group scaling is enabled for Service Group with name serviceGroupName
 * @param serviceGroupName name of the Service Group
 * @return true if group scaling is enabled, else false
 * @throws ApplicationDefinitionException if no Service Group found for the given serviceGroupName
 */
private boolean isGroupScalingEnabled(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
  ServiceGroup nestedGroup=getNestedServiceGroup(serviceGroupName,serviceGroup);
  if (nestedGroup == null) {
    handleError("String_Node_Str" + serviceGroupName);
  }
  return nestedGroup.isGroupscalingEnabled();
}
Program: 116165
Project: 116165
Buggy source:
/** 
 * Find the startup order
 * @param groupContext GroupContext with Group defintion information
 * @return Set of Startup Orders which are defined in the Group
 * @throws ApplicationDefinitionException
 */
private String[] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException {
}

Fixed version (ground truth):
/** 
 * Find the startup order
 * @param groupContext GroupContext with Group defintion information
 * @return Set of Startup Orders which are defined in the Group
 * @throws ApplicationDefinitionException
 */
private String[] getStartupOrderForGroup(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
}
Program: 116166
Project: 116166
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 start a child monitor on termination of a sub tree
 */
public void startDependencyOnTermination(String parentInstanceId) throws TopologyInConsistentException {
}

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 start a child monitor on termination of a sub tree
 */
public void startDependencyOnTermination() throws TopologyInConsistentException {
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependenciesByTermination();
  for (  ApplicationChildContext context : applicationContexts) {
    if (context instanceof GroupChildContext) {
      GroupMonitor groupMonitor=(GroupMonitor)this.aliasToActiveMonitorsMap.get(context.getId());
    }
 else     if (context instanceof ClusterChildContext) {
    }
  }
}
Program: 116167
Project: 116167
Buggy source:
/** 
 * Act upon one of its children got terminated
 * @param eventId id of the notifier
 */
protected void onChildTerminatedEvent(String eventId,String instanceId){
  List<ApplicationChildContext> terminationList;
  boolean allDependentTerminated=false;
  ApplicationChildContext context=this.startupDependencyTree.findApplicationContextWithIdInPrimaryTree(eventId);
  context.setTerminated(true);
  terminationList=this.startupDependencyTree.getTerminationDependencies(eventId);
  if (terminationList != null) {
    allDependentTerminated=allDependentTerminated(terminationList);
  }
  List<ApplicationChildContext> parentContexts=this.startupDependencyTree.findAllParentContextWithId(eventId);
  boolean parentsTerminated=false;
  boolean allParentsActive=false;
  if (parentContexts != null) {
    parentsTerminated=allParentTerminated(parentContexts,instanceId);
    allParentsActive=allParentActive(parentContexts,instanceId);
  }
  if ((terminationList.isEmpty() || allDependentTerminated) && (parentContexts.isEmpty() || parentsTerminated || allParentsActive)) {
    try {
      this.startDependencyOnTermination(parentInstanceId);
    }
 catch (    TopologyInConsistentException e) {
      log.error("String_Node_Str" + e);
    }
  }
 else {
    ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
    log.info("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Act upon one of its children got terminated
 * @param eventId id of the notifier
 */
protected void onChildTerminatedEvent(String eventId,String instanceId){
  List<ApplicationChildContext> terminationList;
  boolean allDependentTerminated=false;
  ApplicationChildContext context=this.startupDependencyTree.findApplicationContextWithIdInPrimaryTree(eventId);
  context.setTerminated(true);
  terminationList=this.startupDependencyTree.getTerminationDependencies(eventId);
  if (terminationList != null) {
    allDependentTerminated=allDependentTerminated(terminationList);
  }
  List<ApplicationChildContext> parentContexts=this.startupDependencyTree.findAllParentContextWithId(eventId);
  boolean parentsTerminated=false;
  boolean allParentsActive=false;
  if (parentContexts != null) {
    parentsTerminated=allParentTerminated(parentContexts,instanceId);
    allParentsActive=allParentActive(parentContexts,instanceId);
  }
  if ((terminationList.isEmpty() || allDependentTerminated) && (parentContexts.isEmpty() || parentsTerminated || allParentsActive)) {
    try {
      this.startDependencyOnTermination();
    }
 catch (    TopologyInConsistentException e) {
      log.error("String_Node_Str" + e);
    }
  }
 else {
    ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
    log.info("String_Node_Str");
  }
}
Program: 116170
Project: 116170
Buggy source:
public static void sendClusterInstanceCreatedEvent(ClusterInstanceCreatedEvent clusterInstanceCreatedEvent){
  if (log.isInfoEnabled()) {
    log.info(String.format("String_Node_Str" + "String_Node_Str",clusterInstanceCreatedEvent.getServiceName(),clusterInstanceCreatedEvent.getClusterId(),clusterInstanceCreatedEvent.getNetworkPartitionId(),clusterInstanceCreatedEvent.getInstanceId()));
  }
  publishEvent(clusterInstanceCreatedEvent);
}

Fixed version (ground truth):
public static void sendClusterInstanceCreatedEvent(ClusterInstanceCreatedEvent clusterInstanceCreatedEvent){
  if (log.isInfoEnabled()) {
    log.info(String.format("String_Node_Str" + "String_Node_Str",clusterInstanceCreatedEvent.getServiceName(),clusterInstanceCreatedEvent.getClusterId(),clusterInstanceCreatedEvent.getNetworkPartitionId(),clusterInstanceCreatedEvent.getClusterInstance().getInstanceId()));
  }
  publishEvent(clusterInstanceCreatedEvent);
}
Program: 116171
Project: 116171
Buggy source:
/** 
 * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
 * @param appId Application id
 * @param groupName Group name
 * @param cartridgeInfo Cartridge information
 * @param subscriptionKey Generated key for the Application
 * @param tenantId Tenant Id of the tenant which deployed the Application
 * @param repoUrl Repository URL
 * @param alias alias specified for this Subscribable in the Application Definition
 * @param clusterId Cluster id
 * @param hostname Hostname
 * @param deploymentPolicy Deployment policy used
 * @param isLB if this cluster is an LB
 * @return ApplicationClusterContext object with relevant information
 * @throws ApplicationDefinitionException If any error occurs
 */
private ApplicationClusterContext createApplicationClusterContext(String appId,String groupName,CartridgeInfo cartridgeInfo,String subscriptionKey,int tenantId,String repoUrl,String alias,String clusterId,String hostname,String deploymentPolicy,boolean isLB,String[] dependencyAliases,Properties properties) throws ApplicationDefinitionException {
  PayloadData payloadData=ApplicationUtils.createPayload(appId,groupName,cartridgeInfo,subscriptionKey,tenantId,clusterId,hostname,repoUrl,alias,null,dependencyAliases,properties);
  payloadData.add("String_Node_Str",createToken(appId));
  String textPayload=payloadData.toString();
  return new ApplicationClusterContext(cartridgeInfo.getType(),clusterId,hostname,textPayload,deploymentPolicy,isLB);
}

Fixed version (ground truth):
/** 
 * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
 * @param appId Application id
 * @param groupName Group name
 * @param cartridgeInfo Cartridge information
 * @param subscriptionKey Generated key for the Application
 * @param tenantId Tenant Id of the tenant which deployed the Application
 * @param repoUrl Repository URL
 * @param alias alias specified for this Subscribable in the Application Definition
 * @param clusterId Cluster id
 * @param hostname Hostname
 * @param deploymentPolicy Deployment policy used
 * @param isLB if this cluster is an LB
 * @return ApplicationClusterContext object with relevant information
 * @throws ApplicationDefinitionException If any error occurs
 */
private ApplicationClusterContext createApplicationClusterContext(String appId,String groupName,CartridgeInfo cartridgeInfo,String subscriptionKey,int tenantId,String repoUrl,String alias,String clusterId,String hostname,String deploymentPolicy,boolean isLB,String[] dependencyAliases,Properties properties) throws ApplicationDefinitionException {
  PayloadData payloadData=ApplicationUtils.createPayload(appId,groupName,cartridgeInfo,subscriptionKey,tenantId,clusterId,hostname,repoUrl,alias,null,dependencyAliases,properties);
  String textPayload=payloadData.toString();
  return new ApplicationClusterContext(cartridgeInfo.getType(),clusterId,hostname,textPayload,deploymentPolicy,isLB);
}
Program: 116173
Project: 116173
Buggy source:
public static void handleGroupInstanceTerminatedEvent(String appId,String groupId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupInstance context=group.getInstanceContexts(instanceId);
  GroupStatus status=GroupStatus.Terminated;
  if (context != null) {
    if (context.isStateTransitionValid(status)) {
      updateGroupMonitor(appId,groupId,status,instanceId);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendGroupInstanceTerminatedEvent(appId,groupId,instanceId);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId+ "String_Node_Str"+ context.getStatus()+ "String_Node_Str"+ status);
    }
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
  }
}

Fixed version (ground truth):
public static void handleGroupInstanceTerminatedEvent(String appId,String groupId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupInstance context=group.getInstanceContexts(instanceId);
  GroupStatus status=GroupStatus.Terminated;
  if (context != null) {
    if (context.isStateTransitionValid(status)) {
      context.setStatus(status);
      updateGroupMonitor(appId,groupId,status,instanceId);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendGroupInstanceTerminatedEvent(appId,groupId,instanceId);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId+ "String_Node_Str"+ context.getStatus()+ "String_Node_Str"+ status);
    }
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
  }
}