nus-yam/ex-repair huggingface dataset:
Program: 115738
Project: 115738
Buggy source:
/** 
 * This will start the child monitors based on the active of siblings according to start up order
 * @param childId parent id of the event which received
 */
protected void onChildActivatedEvent(String childId,String instanceId){
  try {
    removeInstanceFromFromInactiveMap(childId,instanceId);
    removeInstanceFromFromTerminatingMap(childId,instanceId);
    boolean startDep=false;
    if (!aliasToActiveChildMonitorsMap.containsKey(childId) || !pendingChildMonitorsList.contains(childId)) {
      startDep=startDependency(childId,instanceId);
    }
    if (!startDep) {
      ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
    }
 else {
      log.info("String_Node_Str" + startDep + "String_Node_Str"+ this.id);
    }
  }
 catch (  MonitorNotFoundException e) {
    log.error(e);
  }
}

Fixed version (ground truth):
/** 
 * This will start the child monitors based on the active of siblings according to start up order
 * @param childId parent id of the event which received
 */
protected void onChildActivatedEvent(String childId,String instanceId){
  removeInstanceFromFromInactiveMap(childId,instanceId);
  removeInstanceFromFromTerminatingMap(childId,instanceId);
  boolean startDep=false;
  if (!aliasToActiveChildMonitorsMap.containsKey(childId) || !pendingChildMonitorsList.contains(childId)) {
    startDep=startDependency(childId,instanceId);
  }
  if (!startDep) {
    ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
  }
 else {
    log.info("String_Node_Str" + startDep + "String_Node_Str"+ childId+ "String_Node_Str"+ appId+ "String_Node_Str"+ getMonitorType()+ "String_Node_Str"+ id);
  }
}
Program: 115739
Project: 115739
Buggy source:
public void startScheduler(){
  schedulerFuture=scheduler.scheduleAtFixedRate(this,0,monitoringIntervalMilliseconds,TimeUnit.MILLISECONDS);
}

Fixed version (ground truth):
/** 
 * Starting the scheduler for the monitor
 */
public void startScheduler(){
  schedulerFuture=scheduler.scheduleAtFixedRate(this,0,monitoringIntervalMilliseconds,TimeUnit.MILLISECONDS);
}
Program: 115741
Project: 115741
Buggy source:
private boolean doProcess(String clusterId,String instanceId){
  ClusterMonitor monitor=(ClusterMonitor)AutoscalerContext.getInstance().getClusterMonitor(clusterId);
  boolean clusterActive=false;
  for (  ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext : monitor.getNetworkPartitionCtxts()) {
    ClusterInstanceContext instanceContext=(ClusterInstanceContext)clusterLevelNetworkPartitionContext.getInstanceContext(instanceId);
    if (instanceContext != null) {
      if (instanceContext.getActiveMembers() >= instanceContext.getMinInstanceCount()) {
        clusterActive=true;
        break;
      }
 else {
        clusterActive=false;
        break;
      }
    }
 else {
      clusterActive=false;
      break;
    }
  }
  if (clusterActive) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + monitor.getAppId() + "String_Node_Str"+ clusterId);
    }
    ClusterStatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),monitor.getServiceId(),monitor.getClusterId(),instanceId);
  }
  return clusterActive;
}

Fixed version (ground truth):
private boolean doProcess(String clusterId,String instanceId){
  ClusterMonitor monitor=AutoscalerContext.getInstance().getClusterMonitor(clusterId);
  boolean clusterActive=false;
  for (  ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext : monitor.getNetworkPartitionCtxts()) {
    ClusterInstanceContext instanceContext=(ClusterInstanceContext)clusterLevelNetworkPartitionContext.getInstanceContext(instanceId);
    if (instanceContext != null) {
      if (instanceContext.getActiveMembers() >= instanceContext.getMinInstanceCount()) {
        clusterActive=true;
      }
      break;
    }
  }
  if (clusterActive) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + monitor.getAppId() + "String_Node_Str"+ clusterId);
    }
    ClusterStatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),monitor.getServiceId(),monitor.getClusterId(),instanceId);
  }
  return clusterActive;
}
Program: 115742
Project: 115742
Buggy source:
private boolean getClusterInactive(String instanceId,ClusterMonitor monitor){
  boolean clusterInactive=false;
  for (  ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
    ClusterInstanceContext instanceContext=(ClusterInstanceContext)clusterLevelNetworkPartitionContext.getInstanceContext(instanceId);
    if (instanceContext != null) {
      if (instanceContext.getActiveMembers() < instanceContext.getMinInstanceCount()) {
        clusterInactive=true;
        break;
      }
 else {
        clusterInactive=false;
        break;
      }
    }
 else {
      clusterInactive=false;
      break;
    }
  }
  return clusterInactive;
}

Fixed version (ground truth):
private boolean getClusterInactive(String instanceId,ClusterMonitor monitor){
  boolean clusterInactive=false;
  for (  ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
    ClusterInstanceContext instanceContext=(ClusterInstanceContext)clusterLevelNetworkPartitionContext.getInstanceContext(instanceId);
    if (instanceContext != null) {
      if (instanceContext.getActiveMembers() < instanceContext.getMinInstanceCount()) {
        clusterInactive=true;
      }
      break;
    }
  }
  return clusterInactive;
}
Program: 115743
Project: 115743
Buggy source:
/** 
 * Find out whether cluster monitor has any non terminated members
 * @param monitor the cluster monitor
 * @return whether has members or not
 */
private boolean clusterInstanceHasMembers(ClusterMonitor monitor,String instanceId){
  boolean hasMember=false;
  for (  ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
    if (clusterLevelNetworkPartitionContext.containsInstanceContext(instanceId)) {
      ClusterInstanceContext clusterInstanceContext=(ClusterInstanceContext)clusterLevelNetworkPartitionContext.getInstanceContext(instanceId);
      if (clusterInstanceContext != null) {
        for (        ClusterLevelPartitionContext partitionContext : clusterInstanceContext.getPartitionCtxts()) {
          if (partitionContext.getNonTerminatedMemberCount() > 0) {
            hasMember=true;
            return hasMember;
          }
 else {
            hasMember=false;
          }
        }
      }
 else {
        hasMember=false;
        return hasMember;
      }
    }
  }
  return hasMember;
}

Fixed version (ground truth):
/** 
 * Find out whether cluster monitor has any non terminated members
 * @param monitor the cluster monitor
 * @return whether has members or not
 */
private boolean clusterInstanceHasMembers(ClusterMonitor monitor,String instanceId){
  boolean hasMember=false;
  for (  ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext : monitor.getAllNetworkPartitionCtxts().values()) {
    if (clusterLevelNetworkPartitionContext.containsInstanceContext(instanceId)) {
      ClusterInstanceContext clusterInstanceContext=(ClusterInstanceContext)clusterLevelNetworkPartitionContext.getInstanceContext(instanceId);
      if (clusterInstanceContext != null) {
        for (        ClusterLevelPartitionContext partitionContext : clusterInstanceContext.getPartitionCtxts()) {
          if (partitionContext.getNonTerminatedMemberCount() > 0) {
            hasMember=true;
            return hasMember;
          }
 else {
            hasMember=false;
          }
        }
      }
    }
  }
  return hasMember;
}
Program: 115744
Project: 115744
Buggy source:
/** 
 * Un deploy kubernetes host cluster.
 * @param kubernetesClusterId the kubernetes cluster id
 * @return 204 if Kubernetes cluster is successfully removed, 404 if the specified Kubernetes cluster is not found
 * @throws RestAPIException the rest api exception
 */
@DELETE @Path("String_Node_Str") @Produces("String_Node_Str") @Consumes("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response removeKubernetesHostCluster(@PathParam("String_Node_Str") String kubernetesClusterId) throws RestAPIException {
  try {
    StratosApiV41Utils.removeKubernetesCluster(kubernetesClusterId);
  }
 catch (  RestAPIException e) {
    return Response.status(Response.Status.NOT_FOUND).entity(new SuccessResponseBean(Response.Status.NOT_FOUND.getStatusCode(),String.format("String_Node_Str",kubernetesClusterId))).build();
  }
  return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),String.format("String_Node_Str",kubernetesClusterId))).build();
}

Fixed version (ground truth):
/** 
 * Un deploy kubernetes host cluster.
 * @param kubernetesClusterId the kubernetes cluster id
 * @return 204 if Kubernetes cluster is successfully removed, 404 if the specified Kubernetes cluster is not found
 * @throws RestAPIException the rest api exception
 */
@DELETE @Path("String_Node_Str") @Produces("String_Node_Str") @Consumes("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response removeKubernetesHostCluster(@PathParam("String_Node_Str") String kubernetesClusterId) throws RestAPIException {
  try {
    StratosApiV41Utils.removeKubernetesCluster(kubernetesClusterId);
  }
 catch (  CloudControllerServiceNonExistingKubernetesClusterExceptionException e) {
    return Response.status(Response.Status.NOT_FOUND).entity(new SuccessResponseBean(Response.Status.NOT_FOUND.getStatusCode(),String.format("String_Node_Str",kubernetesClusterId))).build();
  }
  return Response.ok().entity(new SuccessResponseBean(Response.Status.OK.getStatusCode(),String.format("String_Node_Str",kubernetesClusterId))).build();
}
Program: 115745
Project: 115745
Buggy source:
public static boolean removeKubernetesCluster(String kubernetesClusterId) throws RestAPIException {
  CloudControllerServiceClient cloudControllerServiceClient=getCloudControllerServiceClient();
  if (cloudControllerServiceClient != null) {
    try {
      return cloudControllerServiceClient.undeployKubernetesCluster(kubernetesClusterId);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
catch (    CloudControllerServiceNonExistingKubernetesClusterExceptionException e) {
      String message=e.getFaultMessage().getNonExistingKubernetesClusterException().getMessage();
      log.error(message,e);
      throw new RestAPIException(message,e);
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean removeKubernetesCluster(String kubernetesClusterId) throws RestAPIException, CloudControllerServiceNonExistingKubernetesClusterExceptionException {
  CloudControllerServiceClient cloudControllerServiceClient=getCloudControllerServiceClient();
  if (cloudControllerServiceClient != null) {
    try {
      return cloudControllerServiceClient.undeployKubernetesCluster(kubernetesClusterId);
    }
 catch (    RemoteException e) {
      log.error(e.getMessage(),e);
      throw new RestAPIException(e.getMessage(),e);
    }
  }
  return false;
}
Program: 115748
Project: 115748
Buggy source:
private List<ApplicationChildContext> findAllParent(List<ApplicationChildContext> parentContexts,String id){
  ApplicationChildContext context=findParentContextWithId(null,id,this.primaryApplicationContextList);
  if (context != null) {
    parentContexts.add(context);
    findAllParent(parentContexts,context.getId());
  }
  return parentContexts;
}

Fixed version (ground truth):
private List<ApplicationChildContext> findAllParent(List<ApplicationChildContext> parentContexts,ApplicationChildContext context){
  if (context.getParent() != null) {
    parentContexts.add(context.getParent());
    return findAllParent(parentContexts,context.getParent());
  }
  return parentContexts;
}
Program: 115749
Project: 115749
Buggy source:
private ApplicationChildContext findParentContextWithId(ApplicationChildContext parent,String id,List<ApplicationChildContext> contexts){
  for (  ApplicationChildContext context : contexts) {
    if (context.getParent() != null && context.getParent().equals(id)) {
      return context;
    }
  }
  for (  ApplicationChildContext context : this.primaryApplicationContextList) {
    if (context.getApplicationChildContextList() != null && !context.getApplicationChildContextList().isEmpty()) {
      return findParentContextWithId(context,id,context.getApplicationChildContextList());
    }
  }
  return null;
}

Fixed version (ground truth):
public ApplicationChildContext findParentContextWithId(String id){
  ApplicationChildContext context=getApplicationChildContextByIdInPrimaryTree(id);
  return context.getParent();
}
Program: 115750
Project: 115750
Buggy source:
public List<ApplicationChildContext> findAllParentContextWithId(String id){
  List<ApplicationChildContext> applicationContexts=new ArrayList<ApplicationChildContext>();
  return findAllParent(applicationContexts,id);
}

Fixed version (ground truth):
public List<ApplicationChildContext> findAllParentContextWithId(String id){
  ApplicationChildContext context=getApplicationChildContextByIdInPrimaryTree(id);
  List<ApplicationChildContext> applicationContexts=new ArrayList<ApplicationChildContext>();
  return findAllParent(applicationContexts,context);
}
Program: 115753
Project: 115753
Buggy source:
/** 
 * Triggered when a scaling event is received from a child.
 * @param scalingEvent
 */
public abstract void onChildScalingEvent(ScalingEvent scalingEvent);

Fixed version (ground truth):
/** 
 * Triggered when a scaling event is received from a child.
 * @param scalingEvent the event which passed when scaling
 */
public abstract void onChildScalingEvent(ScalingEvent scalingEvent);
Program: 115754
Project: 115754
Buggy source:
/** 
 * Triggered when a status event is received from the parent.
 * @param statusEvent
 */
public abstract void onParentStatusEvent(MonitorStatusEvent statusEvent) throws MonitorNotFoundException ;

Fixed version (ground truth):
/** 
 * Triggered when a status event is received from the parent.
 * @param statusEvent
 * @throws MonitorNotFoundException
 */
public abstract void onParentStatusEvent(MonitorStatusEvent statusEvent) throws MonitorNotFoundException ;
Program: 115755
Project: 115755
Buggy source:
/** 
 * This will destroy the monitor thread
 */
public abstract void destroy();

Fixed version (ground truth):
/** 
 * Implement this method to destroy the monitor thread
 */
public abstract void destroy();
Program: 115756
Project: 115756
Buggy source:
/** 
 * This will add the instance
 * @param instance instance to be added
 */
public void addInstance(Instance instance){
  this.instanceIdToInstanceMap.put(instance.getInstanceId(),instance);
}

Fixed version (ground truth):
/** 
 * This will add the instance
 * @param instance instance to be added
 */
public void addInstance(Instance instance){
  instanceIdToInstanceMap.put(instance.getInstanceId(),instance);
}
Program: 115757
Project: 115757
Buggy source:
/** 
 * This will remove the instance
 * @param instanceId instance id
 */
public void removeInstance(String instanceId){
  this.instanceIdToInstanceMap.remove(instanceId);
}

Fixed version (ground truth):
/** 
 * This will remove the instance
 * @param instanceId instance id
 */
public void removeInstance(String instanceId){
  instanceIdToInstanceMap.remove(instanceId);
}
Program: 115758
Project: 115758
Buggy source:
/** 
 * Using instanceId, instance can be retrieved
 * @param instanceId instance id
 * @return the instance
 */
public Instance getInstance(String instanceId){
  return this.instanceIdToInstanceMap.get(instanceId);
}

Fixed version (ground truth):
/** 
 * Using instanceId, instance can be retrieved
 * @param instanceId instance id
 * @return the instance
 */
public Instance getInstance(String instanceId){
  return instanceIdToInstanceMap.get(instanceId);
}
Program: 115759
Project: 115759
Buggy source:
/** 
 * This will return all the instances which has the same parent id as given
 * @param parentInstanceId parent instance id
 * @return all the instances
 */
public List<String> getInstancesByParentInstanceId(String parentInstanceId){
  List<String> instances=new ArrayList<String>();
  for (  Instance instance : this.instanceIdToInstanceMap.values()) {
    if (instance.getParentId().equals(parentInstanceId)) {
      instances.add(instance.getInstanceId());
    }
  }
  return instances;
}

Fixed version (ground truth):
/** 
 * This will return all the instances which has the same parent id as given
 * @param parentInstanceId parent instance id
 * @return all the instances
 */
public List<String> getInstancesByParentInstanceId(String parentInstanceId){
  List<String> instances=new ArrayList<String>();
  for (  Instance instance : instanceIdToInstanceMap.values()) {
    if (instance.getParentId().equals(parentInstanceId)) {
      instances.add(instance.getInstanceId());
    }
  }
  return instances;
}
Program: 115760
Project: 115760
Buggy source:
/** 
 * To set whether monitor has any startup dependencies
 * @param hasDependent whether monitor has dependent or not
 */
public void setHasStartupDependents(boolean hasDependent){
  this.hasStartupDependents=hasDependent;
}

Fixed version (ground truth):
/** 
 * To set whether monitor has any startup dependencies
 * @param hasDependent whether monitor has dependent or not
 */
public void setHasStartupDependents(boolean hasDependent){
  hasStartupDependents=hasDependent;
}
Program: 115761
Project: 115761
Buggy source:
@Override public void onChildStatusEvent(MonitorStatusEvent statusEvent){
  String childId=statusEvent.getId();
  String instanceId=statusEvent.getInstanceId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
    onChildActivatedEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    this.markInstanceAsInactive(childId,instanceId);
    onChildInactiveEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
    markInstanceAsTerminating(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    removeInstanceFromFromInactiveMap(childId,instanceId);
    removeInstanceFromFromTerminatingMap(childId,instanceId);
    ApplicationInstance instance=(ApplicationInstance)instanceIdToInstanceMap.get(instanceId);
    if (instance != null) {
      if (this.isTerminating()) {
        ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,appId,instanceId);
      }
 else {
        onChildTerminatedEvent(childId,instanceId);
      }
    }
 else {
      log.warn("String_Node_Str" + this.id);
    }
  }
}

Fixed version (ground truth):
@Override public void onChildStatusEvent(MonitorStatusEvent statusEvent){
  String childId=statusEvent.getId();
  String instanceId=statusEvent.getInstanceId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) {
    onChildActivatedEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    this.markInstanceAsInactive(childId,instanceId);
    onChildInactiveEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
    markInstanceAsTerminating(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    removeInstanceFromFromInactiveMap(childId,instanceId);
    removeInstanceFromFromTerminatingMap(childId,instanceId);
    ApplicationInstance instance=(ApplicationInstance)instanceIdToInstanceMap.get(instanceId);
    if (instance != null) {
      if (this.isTerminating()) {
        ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,appId,instanceId);
      }
 else {
        Monitor monitor=this.getMonitor(childId);
        boolean active=false;
        if (monitor instanceof GroupMonitor) {
          active=verifyGroupStatus(childId,instanceId,GroupStatus.Active);
        }
        if (!active) {
          onChildTerminatedEvent(childId,instanceId);
        }
 else {
          log.info("String_Node_Str" + instanceId + "String_Node_Str"+ "String_Node_Str"+ childId);
        }
      }
    }
 else {
      log.warn("String_Node_Str" + this.id);
    }
  }
}
Program: 115762
Project: 115762
Buggy source:
/** 
 * Utility method to find the group monitor recursively within app monitor
 * @param id       the unique alias of the Group
 * @param monitors the group monitors found in the app monitor
 * @return the found GroupMonitor
 */
private Monitor findGroupMonitor(String id,Map<String,Monitor> monitors){
  if (monitors.containsKey(id)) {
    return monitors.get(id);
  }
  for (  Monitor monitor : monitors.values()) {
    if (monitor instanceof ParentComponentMonitor) {
      Monitor monitor1=findGroupMonitor(id,((ParentComponentMonitor)monitor).getAliasToActiveMonitorsMap());
      if (monitor1 != null) {
        return monitor1;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Utility method to find the group monitor recursively within app monitor
 * @param id       the unique alias of the Group
 * @param monitors the group monitors found in the app monitor
 * @return the found GroupMonitor
 */
private Monitor findGroupMonitor(String id,Map<String,Monitor> monitors){
  if (monitors.containsKey(id)) {
    return monitors.get(id);
  }
  for (  Monitor monitor : monitors.values()) {
    if (monitor instanceof ParentComponentMonitor) {
      Monitor groupMonitor=findGroupMonitor(id,((ParentComponentMonitor)monitor).getAliasToActiveMonitorsMap());
      if (groupMonitor != null) {
        return groupMonitor;
      }
    }
  }
  return null;
}
Program: 115763
Project: 115763
Buggy source:
@Override public void onChildStatusEvent(MonitorStatusEvent statusEvent){
  String childId=statusEvent.getId();
  String instanceId=statusEvent.getInstanceId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == GroupStatus.Active) {
    boolean isChildActive=verifyGroupStatus(childId,instanceId,GroupStatus.Active);
    if (isChildActive) {
      onChildActivatedEvent(childId,instanceId);
    }
 else {
      log.info("String_Node_Str");
    }
  }
 else   if (status1 == ClusterStatus.Active) {
    onChildActivatedEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    markInstanceAsInactive(childId,instanceId);
    onChildInactiveEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
    markInstanceAsTerminating(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    if (status1 == GroupStatus.Terminated) {
      onTerminationOfInstance(childId,instanceId);
    }
 else {
      onTerminationOfInstance(childId,instanceId);
    }
  }
}

Fixed version (ground truth):
@Override public void onChildStatusEvent(MonitorStatusEvent statusEvent){
  String childId=statusEvent.getId();
  String instanceId=statusEvent.getInstanceId();
  LifeCycleState status1=statusEvent.getStatus();
  if (status1 == GroupStatus.Active) {
    boolean isChildActive=verifyGroupStatus(childId,instanceId,GroupStatus.Active);
    if (isChildActive) {
      onChildActivatedEvent(childId,instanceId);
    }
 else {
      log.info("String_Node_Str");
    }
  }
 else   if (status1 == ClusterStatus.Active) {
    onChildActivatedEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) {
    markInstanceAsInactive(childId,instanceId);
    onChildInactiveEvent(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
    markInstanceAsTerminating(childId,instanceId);
  }
 else   if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
    onTerminationOfInstance(childId,instanceId);
  }
}
Program: 115764
Project: 115764
Buggy source:
private void onTerminationOfInstance(String childId,String instanceId){
  removeInstanceFromFromInactiveMap(childId,instanceId);
  removeInstanceFromFromTerminatingMap(childId,instanceId);
  GroupInstance instance=(GroupInstance)instanceIdToInstanceMap.get(instanceId);
  if (instance != null) {
    if (instance.getStatus() == GroupStatus.Terminating || instance.getStatus() == GroupStatus.Terminated) {
      ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(id,appId,instanceId);
    }
 else {
      onChildTerminatedEvent(childId,instanceId);
    }
  }
 else {
    log.warn("String_Node_Str" + id);
  }
}

Fixed version (ground truth):
private void onTerminationOfInstance(String childId,String instanceId){
  removeInstanceFromFromInactiveMap(childId,instanceId);
  removeInstanceFromFromTerminatingMap(childId,instanceId);
  GroupInstance instance=(GroupInstance)instanceIdToInstanceMap.get(instanceId);
  if (instance != null) {
    if (instance.getStatus() == GroupStatus.Terminating || instance.getStatus() == GroupStatus.Terminated) {
      ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(id,appId,instanceId);
    }
 else {
      boolean active=verifyGroupStatus(childId,instanceId,GroupStatus.Active);
      if (!active) {
        onTerminationOfInstance(childId,instanceId);
      }
 else {
        log.info("String_Node_Str" + instanceId + "String_Node_Str"+ "String_Node_Str"+ childId);
      }
    }
  }
 else {
    log.warn("String_Node_Str" + id);
  }
}
Program: 115767
Project: 115767
Buggy source:
private void onTerminationOfInstance(String childId,String instanceId){
  removeInstanceFromFromInactiveMap(childId,instanceId);
  removeInstanceFromFromTerminatingMap(childId,instanceId);
  GroupInstance instance=(GroupInstance)instanceIdToInstanceMap.get(instanceId);
  if (instance != null) {
    if (instance.getStatus() == GroupStatus.Terminating || instance.getStatus() == GroupStatus.Terminated) {
      ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(id,appId,instanceId);
    }
 else {
      boolean active=verifyGroupStatus(childId,instanceId,GroupStatus.Active);
      if (!active) {
        onTerminationOfInstance(childId,instanceId);
      }
 else {
        log.info("String_Node_Str" + instanceId + "String_Node_Str"+ "String_Node_Str"+ childId);
      }
    }
  }
 else {
    log.warn("String_Node_Str" + id);
  }
}

Fixed version (ground truth):
private void onTerminationOfInstance(String childId,String instanceId){
  removeInstanceFromFromInactiveMap(childId,instanceId);
  removeInstanceFromFromTerminatingMap(childId,instanceId);
  GroupInstance instance=(GroupInstance)instanceIdToInstanceMap.get(instanceId);
  if (instance != null) {
    if (instance.getStatus() == GroupStatus.Terminating || instance.getStatus() == GroupStatus.Terminated) {
      ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(id,appId,instanceId);
    }
 else {
      boolean active=verifyGroupStatus(childId,instanceId,GroupStatus.Active);
      if (!active) {
        onChildTerminatedEvent(childId,instanceId);
      }
 else {
        log.info("String_Node_Str" + instanceId + "String_Node_Str"+ "String_Node_Str"+ childId);
      }
    }
  }
 else {
    log.warn("String_Node_Str" + id);
  }
}
Program: 115769
Project: 115769
Buggy source:
private ApplicationChildContext findParentContextWithId(ApplicationChildContext parent,String id,List<ApplicationChildContext> contexts){
  for (  ApplicationChildContext context : contexts) {
    if (context.getId().equals(id)) {
      return context;
    }
  }
  for (  ApplicationChildContext context : this.primaryApplicationContextList) {
    return findParentContextWithId(context,id,context.getApplicationChildContextList());
  }
  return null;
}

Fixed version (ground truth):
private ApplicationChildContext findParentContextWithId(ApplicationChildContext parent,String id,List<ApplicationChildContext> contexts){
  for (  ApplicationChildContext context : contexts) {
    if (context.getParent() != null && context.getParent().equals(id)) {
      return context;
    }
  }
  for (  ApplicationChildContext context : this.primaryApplicationContextList) {
    if (context.getApplicationChildContextList() != null && !context.getApplicationChildContextList().isEmpty()) {
      return findParentContextWithId(context,id,context.getApplicationChildContextList());
    }
  }
  return null;
}
Program: 115770
Project: 115770
Buggy source:
/** 
 * Return the type of the monitor.
 * @return
 */
public abstract MonitorType getMonitorType();

Fixed version (ground truth):
/** 
 * Return the type of the monitor.
 * @return monitor type
 */
public abstract MonitorType getMonitorType();
Program: 115771
Project: 115771
Buggy source:
/** 
 * This will check whether instances are there in the map
 * @return true/false
 */
public boolean hasInstance(){
  if (this.instanceIdToInstanceMap.isEmpty()) {
    return false;
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
/** 
 * This will check whether instances are there in the map
 * @return true/false
 */
public boolean hasInstance(){
  return !instanceIdToInstanceMap.isEmpty();
}
Program: 115772
Project: 115772
Buggy source:
public abstract void destroy();

Fixed version (ground truth):
/** 
 * This will destroy the monitor thread
 */
public abstract void destroy();
Program: 115773
Project: 115773
Buggy source:
/** 
 * To set the app id of the monitor
 * @param appId
 */
public void setAppId(String appId){
  this.appId=appId;
}

Fixed version (ground truth):
/** 
 * To set the app id of the monitor
 * @param appId application id
 */
public void setAppId(String appId){
  this.appId=appId;
}
Program: 115774
Project: 115774
Buggy source:
public abstract boolean createInstanceOnDemand(String instanceId);

Fixed version (ground truth):
/** 
 * This will create Instance on demand as requested by monitors
 * @param instanceId instance Id of the instance to be created
 * @return whether it is created or not
 */
public abstract boolean createInstanceOnDemand(String instanceId);
Program: 115775
Project: 115775
Buggy source:
/** 
 * Set the id of the monitor
 * @param id
 */
public void setId(String id){
  this.id=id;
}

Fixed version (ground truth):
/** 
 * Set the id of the monitor
 * @param id id of the monitor
 */
public void setId(String id){
  this.id=id;
}
Program: 115776
Project: 115776
Buggy source:
/** 
 * To set the parent of the monitor
 * @param parent
 */
public void setParent(ParentComponentMonitor parent){
  this.parent=parent;
  this.appId=parent.getAppId();
}

Fixed version (ground truth):
/** 
 * To set the parent of the monitor
 * @param parent parent of the monitor
 */
public void setParent(ParentComponentMonitor parent){
  this.parent=parent;
  this.appId=parent.getAppId();
}
Program: 115777
Project: 115777
Buggy source:
/** 
 * To set whether monitor has any startup dependencies
 * @param hasDependent
 */
public void setHasStartupDependents(boolean hasDependent){
  this.hasStartupDependents=hasDependent;
}

Fixed version (ground truth):
/** 
 * To set whether monitor has any startup dependencies
 * @param hasDependent whether monitor has dependent or not
 */
public void setHasStartupDependents(boolean hasDependent){
  this.hasStartupDependents=hasDependent;
}
Program: 115778
Project: 115778
Buggy source:
public boolean startMinimumDependencies(Application application) throws TopologyInConsistentException, PolicyValidationException {
  return createInstanceAndStartDependency(application);
}

Fixed version (ground truth):
/** 
 * This will start the minimum dependencies
 * @param application the application which used to create monitors
 * @return whether monitor created or not
 * @throws TopologyInConsistentException
 * @throws PolicyValidationException
 */
public boolean startMinimumDependencies(Application application) throws TopologyInConsistentException, PolicyValidationException {
  return createInstanceAndStartDependency(application);
}
Program: 115780
Project: 115780
Buggy source:
private String handleApplicationInstanceCreation(Application application,ApplicationLevelNetworkPartitionContext context,ApplicationInstance instanceExist){
  ApplicationInstance instance;
  ApplicationInstanceContext instanceContext;
  if (instanceExist != null) {
    instance=instanceExist;
  }
 else {
    instance=createApplicationInstance(application,context.getId());
  }
  String instanceId=instance.getInstanceId();
  instanceContext=new ApplicationInstanceContext(instanceId);
  context.addInstanceContext(instanceContext);
  context.addPendingInstance(instanceContext);
  this.instanceIdToInstanceMap.put(instanceId,instance);
  this.getNetworkPartitionCtxts().put(context.getId(),context);
  return instanceId;
}

Fixed version (ground truth):
/** 
 * Utility method to create application instance inside a network partition and add data structure to monitor
 * @param application   the application where the application instance needs to be created
 * @param context       networkPartition where instance needs to be created
 * @param instanceExist whether application instance exists or not
 * @return instance Id
 */
private String handleApplicationInstanceCreation(Application application,ApplicationLevelNetworkPartitionContext context,ApplicationInstance instanceExist){
  ApplicationInstance instance;
  ApplicationInstanceContext instanceContext;
  if (instanceExist != null) {
    instance=instanceExist;
  }
 else {
    instance=createApplicationInstance(application,context.getId());
  }
  String instanceId=instance.getInstanceId();
  instanceContext=new ApplicationInstanceContext(instanceId);
  context.addInstanceContext(instanceContext);
  context.addPendingInstance(instanceContext);
  this.instanceIdToInstanceMap.put(instanceId,instance);
  this.getNetworkPartitionCtxts().put(context.getId(),context);
  return instanceId;
}
Program: 115782
Project: 115782
Buggy source:
public boolean isTerminating(){
  return isTerminating;
}

Fixed version (ground truth):
/** 
 * Whether application is in-terminating or not
 * @return application state
 */
public boolean isTerminating(){
  return isTerminating;
}
Program: 115783
Project: 115783
Buggy source:
/** 
 * 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);
  }
}

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"+ "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: 115784
Project: 115784
Buggy source:
private ApplicationInstance createApplicationInstance(Application application,String networkPartitionId){
  ApplicationInstance instance=ApplicationBuilder.handleApplicationInstanceCreatedEvent(appId,networkPartitionId);
  return instance;
}

Fixed version (ground truth):
/** 
 * Creating application instance into applications Topology
 * @param application        application where instance needs to be added
 * @param networkPartitionId network partition of the application Instance
 * @return the create application instance in the topology
 */
private ApplicationInstance createApplicationInstance(Application application,String networkPartitionId){
  ApplicationInstance instance=ApplicationBuilder.handleApplicationInstanceCreatedEvent(appId,networkPartitionId);
  return instance;
}
Program: 115785
Project: 115785
Buggy source:
private NetworkPartitionAlgorithm getNetworkPartitionAlgorithm(String algorithmName){
  if (algorithmName == null || algorithmName.isEmpty()) {
    return null;
  }
  if (algorithmName.equals(StratosConstants.NETWORK_PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID)) {
    if (log.isDebugEnabled()) {
      String msg=String.format("String_Node_Str",StratosConstants.NETWORK_PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID);
      log.debug(msg);
    }
    return new OneAfterAnotherAlgorithm();
  }
 else   if (algorithmName.equals(StratosConstants.NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID)) {
    if (log.isDebugEnabled()) {
      String msg=String.format("String_Node_Str",StratosConstants.NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID);
      log.debug(msg);
    }
    return new AllAtOnceAlgorithm();
  }
  if (log.isDebugEnabled()) {
    String msg=String.format("String_Node_Str",StratosConstants.NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID);
    log.debug(msg);
  }
  return null;
}

Fixed version (ground truth):
private NetworkPartitionAlgorithm getNetworkPartitionAlgorithm(String algorithmName){
  if (algorithmName == null || algorithmName.isEmpty()) {
    return null;
  }
  if (algorithmName.equals(StratosConstants.NETWORK_PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID)) {
    if (log.isDebugEnabled()) {
      String msg=String.format("String_Node_Str" + "String_Node_Str",StratosConstants.NETWORK_PARTITION_ONE_AFTER_ANOTHER_ALGORITHM_ID);
      log.debug(msg);
    }
    return new OneAfterAnotherAlgorithm();
  }
 else   if (algorithmName.equals(StratosConstants.NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID)) {
    if (log.isDebugEnabled()) {
      String msg=String.format("String_Node_Str" + "String_Node_Str",StratosConstants.NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID);
      log.debug(msg);
    }
    return new AllAtOnceAlgorithm();
  }
  if (log.isDebugEnabled()) {
    String msg=String.format("String_Node_Str" + "String_Node_Str",StratosConstants.NETWORK_PARTITION_ALL_AT_ONCE_ALGORITHM_ID);
    log.debug(msg);
  }
  return null;
}
Program: 115787
Project: 115787
Buggy source:
public ClusterInstanceContext getClusterInstanceContext(String networkPartitionId,String instanceId){
  Map<String,ClusterLevelNetworkPartitionContext> clusterLevelNetworkPartitionContextMap=((ClusterContext)this.clusterContext).getNetworkPartitionCtxts();
  if (StringUtils.isBlank(networkPartitionId)) {
    throw new RuntimeException("String_Node_Str");
  }
  ClusterLevelNetworkPartitionContext networkPartitionContext=clusterLevelNetworkPartitionContextMap.get(networkPartitionId);
  if (networkPartitionContext == null) {
    throw new RuntimeException("String_Node_Str" + networkPartitionId);
  }
  ClusterInstanceContext instanceContext=(ClusterInstanceContext)networkPartitionContext.getInstanceContext(instanceId);
  return instanceContext;
}

Fixed version (ground truth):
public ClusterInstanceContext getClusterInstanceContext(String networkPartitionId,String instanceId){
  Map<String,ClusterLevelNetworkPartitionContext> clusterLevelNetworkPartitionContextMap=((ClusterContext)this.clusterContext).getNetworkPartitionCtxts();
  if (StringUtils.isBlank(networkPartitionId)) {
    throw new RuntimeException("String_Node_Str");
  }
  ClusterLevelNetworkPartitionContext networkPartitionContext=clusterLevelNetworkPartitionContextMap.get(networkPartitionId);
  if (networkPartitionContext == null) {
    throw new RuntimeException("String_Node_Str" + networkPartitionId);
  }
  return (ClusterInstanceContext)networkPartitionContext.getInstanceContext(instanceId);
}
Program: 115789
Project: 115789
Buggy source:
public List<AutoscalePolicy> retrieveASPolicies(){
  try {
    startTenantFlow();
    List<AutoscalePolicy> asPolicyList=new ArrayList<AutoscalePolicy>();
    String[] partitionsResourceList=(String[])retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE);
    if (partitionsResourceList != null) {
      AutoscalePolicy asPolicy;
      for (      String resourcePath : partitionsResourceList) {
        Object serializedObj=retrieve(resourcePath);
        if (serializedObj != null) {
          try {
            Object dataObj=Deserializer.deserializeFromByteArray((byte[])serializedObj);
            if (dataObj instanceof AutoscalePolicy) {
              asPolicy=(AutoscalePolicy)dataObj;
              if (log.isDebugEnabled()) {
                log.debug(String.format("String_Node_Str",asPolicy.getId(),asPolicy.getDisplayName(),asPolicy.getDescription()));
              }
              asPolicyList.add(asPolicy);
            }
 else {
              return null;
            }
          }
 catch (          Exception e) {
            String msg="String_Node_Str" + resourcePath;
            log.warn(msg,e);
          }
        }
      }
    }
    return asPolicyList;
  }
  finally {
    endTenantFlow();
  }
}

Fixed version (ground truth):
/** 
 * Retrieve Autoscaling policies from registry
 * @return all the Autoscaling policies
 */
public List<AutoscalePolicy> retrieveASPolicies(){
  try {
    startTenantFlow();
    List<AutoscalePolicy> asPolicyList=new ArrayList<AutoscalePolicy>();
    String[] partitionsResourceList=(String[])retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.AS_POLICY_RESOURCE);
    if (partitionsResourceList != null) {
      AutoscalePolicy asPolicy;
      for (      String resourcePath : partitionsResourceList) {
        Object serializedObj=retrieve(resourcePath);
        if (serializedObj != null) {
          try {
            Object dataObj=Deserializer.deserializeFromByteArray((byte[])serializedObj);
            if (dataObj instanceof AutoscalePolicy) {
              asPolicy=(AutoscalePolicy)dataObj;
              if (log.isDebugEnabled()) {
                log.debug(String.format("String_Node_Str",asPolicy.getId(),asPolicy.getDisplayName(),asPolicy.getDescription()));
              }
              asPolicyList.add(asPolicy);
            }
 else {
              return null;
            }
          }
 catch (          Exception e) {
            String msg="String_Node_Str" + resourcePath;
            log.warn(msg,e);
          }
        }
      }
    }
    return asPolicyList;
  }
  finally {
    endTenantFlow();
  }
}
Program: 115790
Project: 115790
Buggy source:
public List<DeploymentPolicy> retrieveDeploymentPolicies(){
  List<DeploymentPolicy> depPolicyList=new ArrayList<DeploymentPolicy>();
  RegistryManager registryManager=RegistryManager.getInstance();
  String[] depPolicyResourceList=(String[])registryManager.retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.DEPLOYMENT_POLICY_RESOURCE);
  if (depPolicyResourceList != null) {
    DeploymentPolicy depPolicy;
    for (    String resourcePath : depPolicyResourceList) {
      Object serializedObj=registryManager.retrieve(resourcePath);
      if (serializedObj != null) {
        try {
          Object dataObj=Deserializer.deserializeFromByteArray((byte[])serializedObj);
          if (dataObj instanceof DeploymentPolicy) {
            depPolicy=(DeploymentPolicy)dataObj;
            if (log.isDebugEnabled()) {
              log.debug(depPolicy.toString());
            }
            depPolicyList.add(depPolicy);
          }
 else {
            return null;
          }
        }
 catch (        Exception e) {
          String msg="String_Node_Str";
          log.warn(msg,e);
        }
      }
    }
  }
  return depPolicyList;
}

Fixed version (ground truth):
/** 
 * Retrieve deployment policies from registry
 * @return all the deployment policies
 */
public List<DeploymentPolicy> retrieveDeploymentPolicies(){
  try {
    startTenantFlow();
    List<DeploymentPolicy> depPolicyList=new ArrayList<DeploymentPolicy>();
    RegistryManager registryManager=RegistryManager.getInstance();
    String[] depPolicyResourceList=(String[])registryManager.retrieve(AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.DEPLOYMENT_POLICY_RESOURCE);
    if (depPolicyResourceList != null) {
      DeploymentPolicy depPolicy;
      for (      String resourcePath : depPolicyResourceList) {
        Object serializedObj=registryManager.retrieve(resourcePath);
        if (serializedObj != null) {
          try {
            Object dataObj=Deserializer.deserializeFromByteArray((byte[])serializedObj);
            if (dataObj instanceof DeploymentPolicy) {
              depPolicy=(DeploymentPolicy)dataObj;
              if (log.isDebugEnabled()) {
                log.debug(depPolicy.toString());
              }
              depPolicyList.add(depPolicy);
            }
 else {
              return null;
            }
          }
 catch (          Exception e) {
            String msg="String_Node_Str";
            log.warn(msg,e);
          }
        }
      }
    }
    return depPolicyList;
  }
  finally {
    endTenantFlow();
  }
}
Program: 115791
Project: 115791
Buggy source:
public KubernetesMaster getKubernetesMasterInGroup(String kubernetesClusterId) throws NonExistingKubernetesClusterException {
  if (StringUtils.isEmpty(kubernetesClusterId)) {
    throw new NonExistingKubernetesClusterException("String_Node_Str");
  }
  KubernetesCluster kubernetesCluster=kubernetesClustersMap.get(kubernetesClusterId);
  if (kubernetesCluster != null) {
    return kubernetesCluster.getKubernetesMaster();
  }
  throw new NonExistingKubernetesClusterException("String_Node_Str" + kubernetesClusterId);
}

Fixed version (ground truth):
public KubernetesMaster getKubernetesMasterInGroup(String kubernetesClusterId) throws NonExistingKubernetesClusterException {
  if (StringUtils.isEmpty(kubernetesClusterId)) {
    throw new NonExistingKubernetesClusterException("String_Node_Str");
  }
  KubernetesCluster kubernetesCluster=kubernetesClustersMap.get(kubernetesClusterId);
  if (kubernetesCluster != null) {
    return kubernetesCluster.getKubernetesMaster();
  }
  throw new NonExistingKubernetesClusterException("String_Node_Str" + "String_Node_Str" + kubernetesClusterId);
}
Program: 115793
Project: 115793
Buggy source:
public KubernetesHost[] getKubernetesHostsInGroup(String kubernetesClusterId) throws NonExistingKubernetesClusterException {
  if (StringUtils.isEmpty(kubernetesClusterId)) {
    throw new NonExistingKubernetesClusterException("String_Node_Str");
  }
  KubernetesCluster kubernetesCluster=kubernetesClustersMap.get(kubernetesClusterId);
  if (kubernetesCluster != null) {
    return kubernetesCluster.getKubernetesHosts();
  }
  throw new NonExistingKubernetesClusterException("String_Node_Str" + kubernetesClusterId);
}

Fixed version (ground truth):
public KubernetesHost[] getKubernetesHostsInGroup(String kubernetesClusterId) throws NonExistingKubernetesClusterException {
  if (StringUtils.isEmpty(kubernetesClusterId)) {
    throw new NonExistingKubernetesClusterException("String_Node_Str");
  }
  KubernetesCluster kubernetesCluster=kubernetesClustersMap.get(kubernetesClusterId);
  if (kubernetesCluster != null) {
    return kubernetesCluster.getKubernetesHosts();
  }
  throw new NonExistingKubernetesClusterException("String_Node_Str" + "String_Node_Str" + kubernetesClusterId);
}