nus-yam/ex-repair huggingface dataset:
Program: 115587
Project: 115587
Buggy source:
private void undeployApplicationGracefully(String applicationId){
  try {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + applicationId);
    }
    ApplicationContext applicationContext=AutoscalerContext.getInstance().getApplicationContext(applicationId);
    Application application=ApplicationHolder.getApplications().getApplication(applicationId);
    if ((applicationContext == null) || (application == null)) {
      String msg=String.format("String_Node_Str",applicationId);
      throw new RuntimeException(msg);
    }
    if (!applicationContext.getStatus().equals(ApplicationContext.STATUS_DEPLOYED)) {
      String message=String.format("String_Node_Str",applicationId);
      log.error(message);
      throw new RuntimeException(message);
    }
    applicationContext.setStatus(ApplicationContext.STATUS_UNDEPLOYING);
    removeApplicationSignUp(applicationContext);
    AutoscalerContext.getInstance().removeNetworkPartitionAlgorithmContext(applicationId);
    ApplicationBuilder.handleApplicationUnDeployedEvent(applicationId);
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + applicationId);
    }
  }
 catch (  Exception e) {
    String message="String_Node_Str" + applicationId;
    log.error(message,e);
    throw new RuntimeException(message,e);
  }
}

Fixed version (ground truth):
private void undeployApplicationGracefully(String applicationId){
  try {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + applicationId);
    }
    ApplicationContext applicationContext=AutoscalerContext.getInstance().getApplicationContext(applicationId);
    Application application=ApplicationHolder.getApplications().getApplication(applicationId);
    if ((applicationContext == null) || (application == null)) {
      String msg=String.format("String_Node_Str",applicationId);
      throw new RuntimeException(msg);
    }
    if (!applicationContext.getStatus().equals(ApplicationContext.STATUS_DEPLOYED)) {
      String message=String.format("String_Node_Str",applicationId);
      log.error(message);
      throw new RuntimeException(message);
    }
    applicationContext.setStatus(ApplicationContext.STATUS_UNDEPLOYING);
    removeApplicationSignUp(applicationContext);
    ApplicationBuilder.handleApplicationUnDeployedEvent(applicationId);
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + applicationId);
    }
  }
 catch (  Exception e) {
    String message="String_Node_Str" + applicationId;
    log.error(message,e);
    throw new RuntimeException(message,e);
  }
}
Program: 115588
Project: 115588
Buggy source:
private void checkForMinimumApplicationInstances(Application application,List<String> defaultNetworkPartitions){
  List<String> instanceIds=new ArrayList<String>();
  for (  String networkPartitionId : defaultNetworkPartitions) {
    if (!networkPartitionContextsMap.containsKey(networkPartitionId)) {
      String instanceId;
      log.info("String_Node_Str" + networkPartitionId + "String_Node_Str"+ appId+ "String_Node_Str"+ "String_Node_Str");
      ParentLevelNetworkPartitionContext context=new ParentLevelNetworkPartitionContext(networkPartitionId);
      ApplicationInstance appInstance=(ApplicationInstance)application.getInstanceByNetworkPartitionId(context.getId());
      if (appInstance != null) {
        log.warn("String_Node_Str" + appId + "String_Node_Str"+ "String_Node_Str"+ appInstance.getInstanceId()+ "String_Node_Str"+ "String_Node_Str"+ networkPartitionId);
        return;
      }
      instanceId=handleApplicationInstanceCreation(application,context,null);
      instanceIds.add(instanceId);
    }
  }
  if (instanceIds.isEmpty()) {
    startDependency(application,instanceIds);
  }
}

Fixed version (ground truth):
private void checkForMinimumApplicationInstances(Application application,List<String> defaultNetworkPartitions){
  List<String> instanceIds=new ArrayList<String>();
  for (  String networkPartitionId : defaultNetworkPartitions) {
    if (!networkPartitionContextsMap.containsKey(networkPartitionId)) {
      String instanceId;
      log.info("String_Node_Str" + networkPartitionId + "String_Node_Str"+ appId+ "String_Node_Str"+ "String_Node_Str");
      ParentLevelNetworkPartitionContext context=new ParentLevelNetworkPartitionContext(networkPartitionId);
      ApplicationInstance appInstance=(ApplicationInstance)application.getInstanceByNetworkPartitionId(context.getId());
      if (appInstance != null) {
        log.warn("String_Node_Str" + appId + "String_Node_Str"+ "String_Node_Str"+ appInstance.getInstanceId()+ "String_Node_Str"+ "String_Node_Str"+ networkPartitionId);
        return;
      }
      instanceId=handleApplicationInstanceCreation(application,context,null);
      instanceIds.add(instanceId);
    }
  }
  if (!instanceIds.isEmpty()) {
    startDependency(application,instanceIds);
  }
}
Program: 115590
Project: 115590
Buggy source:
public ApplicationLock getLockForApplication(String appId){
  ApplicationLock applicationLock=appIdToApplicationLockMap.get(appId);
  if (applicationLock == null) {
synchronized (ApplicationLockHierarchy.class) {
      if (applicationLock == null) {
        applicationLock=new ApplicationLock();
        appIdToApplicationLockMap.put(appId,applicationLock);
      }
    }
  }
  return applicationLock;
}

Fixed version (ground truth):
public synchronized ApplicationLock getLockForApplication(String appId){
  ApplicationLock applicationLock=appIdToApplicationLockMap.get(appId);
  if (applicationLock == null) {
    applicationLock=new ApplicationLock();
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + appId + "String_Node_Str"+ applicationLock.toString()+ "String_Node_Str"+ appIdToApplicationLockMap.size());
    }
    appIdToApplicationLockMap.put(appId,applicationLock);
  }
  return applicationLock;
}
Program: 115591
Project: 115591
Buggy source:
private ApplicationLockHierarchy(){
  this.applicationLock=new ApplicationLock();
  this.appIdToApplicationLockMap=new HashMap<String,ApplicationLock>();
}

Fixed version (ground truth):
private ApplicationLockHierarchy(){
  this.applicationLock=new ApplicationLock();
  this.appIdToApplicationLockMap=new ConcurrentHashMap<String,ApplicationLock>();
}
Program: 115592
Project: 115592
Buggy source:
public TopologyLock getTopologyLockForService(String serviceName,boolean forceCreationIfNotFound){
  TopologyLock topologyLock=serviceNameToTopologyLockMap.get(serviceName);
  if (topologyLock == null && forceCreationIfNotFound) {
synchronized (TopologyLockHierarchy.class) {
      if (topologyLock == null) {
        topologyLock=new TopologyLock();
        serviceNameToTopologyLockMap.put(serviceName,topologyLock);
      }
    }
  }
  return topologyLock;
}

Fixed version (ground truth):
public synchronized TopologyLock getTopologyLockForService(String serviceName,boolean forceCreationIfNotFound){
  TopologyLock topologyLock=serviceNameToTopologyLockMap.get(serviceName);
  if (topologyLock == null && forceCreationIfNotFound) {
    topologyLock=new TopologyLock();
    serviceNameToTopologyLockMap.put(serviceName,topologyLock);
  }
  return topologyLock;
}
Program: 115593
Project: 115593
Buggy source:
public TopologyLock getTopologyLockForCluster(String clusterId,boolean forceCreationIfNotFound){
  TopologyLock topologyLock=clusterIdToTopologyLockMap.get(clusterId);
  if (topologyLock == null && forceCreationIfNotFound) {
synchronized (TopologyLockHierarchy.class) {
      if (topologyLock == null) {
        topologyLock=new TopologyLock();
        clusterIdToTopologyLockMap.put(clusterId,topologyLock);
      }
    }
  }
  return topologyLock;
}

Fixed version (ground truth):
public synchronized TopologyLock getTopologyLockForCluster(String clusterId,boolean forceCreationIfNotFound){
  TopologyLock topologyLock=clusterIdToTopologyLockMap.get(clusterId);
  if (topologyLock == null && forceCreationIfNotFound) {
    topologyLock=new TopologyLock();
    clusterIdToTopologyLockMap.put(clusterId,topologyLock);
  }
  return topologyLock;
}
Program: 115594
Project: 115594
Buggy source:
/** 
 * Find out whether all the groups of a group in the same state or not
 * @param groups groups of a group/application
 * @param status the state to check in all groups
 * @return whether groups in the given state or not
 */
protected boolean getAllGroupInSameState(Map<String,Group> groups,GroupStatus status,String instanceId){
  boolean groupStat=false;
  for (  Group group : groups.values()) {
    GroupInstance context=group.getInstanceContexts(instanceId);
    if (context != null) {
      if (context.getStatus() == status) {
        groupStat=true;
      }
 else {
        return false;
      }
    }
 else {
      List<Instance> contexts=group.getInstanceContextsWithParentId(instanceId);
      if (contexts == null || contexts.isEmpty() && status == GroupStatus.Terminated) {
        groupStat=true;
      }
 else {
        int sameStateInstances=0;
        for (        Instance context1 : contexts) {
          if (((GroupInstance)context1).getStatus().equals(status)) {
            sameStateInstances++;
          }
        }
        if (sameStateInstances == contexts.size()) {
          groupStat=true;
        }
 else {
          return false;
        }
      }
    }
  }
  return groupStat;
}

Fixed version (ground truth):
/** 
 * Find out whether all the groups of a group in the same state or not
 * @param groups groups of a group/application
 * @param status the state to check in all groups
 * @return whether groups in the given state or not
 */
protected boolean getAllGroupInSameState(Map<String,Group> groups,GroupStatus status,String instanceId){
  boolean groupStat=false;
  for (  Group group : groups.values()) {
    GroupInstance context=group.getInstanceContexts(instanceId);
    if (context != null) {
      if (context.getStatus() == status) {
        groupStat=true;
      }
 else {
        return false;
      }
    }
 else {
      List<Instance> contexts=group.getInstanceContextsWithParentId(instanceId);
      if (contexts == null || contexts.isEmpty() && status == GroupStatus.Terminated) {
        groupStat=true;
      }
 else {
        for (        Instance context1 : contexts) {
          if (!((GroupInstance)context1).getStatus().equals(status)) {
            return false;
          }
 else {
            groupStat=true;
          }
        }
      }
    }
  }
  return groupStat;
}
Program: 115597
Project: 115597
Buggy source:
/** 
 * Get Application Runtime
 * @param applicationId Application Id
 * @return ApplicationInfoBean
 */
public static ApplicationInfoBean getApplicationRuntime(String applicationId){
  ApplicationInfoBean applicationBean=null;
  try {
    ApplicationManager.acquireReadLockForApplication(applicationId);
    Application application=ApplicationManager.getApplications().getApplication(applicationId);
    if (application == null) {
      return null;
    }
    applicationBean=ObjectConverter.convertApplicationToApplicationInstanceBean(application);
    for (    ApplicationInstanceBean instanceBean : applicationBean.getApplicationInstances()) {
      addClustersInstancesToApplicationInstanceBean(instanceBean,application);
      addGroupsInstancesToApplicationInstanceBean(instanceBean,application);
    }
  }
  finally {
    ApplicationManager.releaseReadLockForApplication(applicationId);
  }
  return applicationBean;
}

Fixed version (ground truth):
/** 
 * Get Application Runtime
 * @param applicationId Application Id
 * @return ApplicationInfoBean
 */
public static ApplicationInfoBean getApplicationRuntime(String applicationId) throws RestAPIException {
  ApplicationInfoBean applicationBean=null;
  ApplicationContext applicationContext=null;
  try {
    applicationContext=getAutoscalerServiceClient().getApplication(applicationId);
  }
 catch (  RemoteException e) {
    String message="String_Node_Str" + applicationId;
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
catch (  RestAPIException e) {
    String message="String_Node_Str" + applicationId;
    log.error(message,e);
    throw new RestAPIException(message,e);
  }
  if (applicationContext != null && applicationContext.getStatus().equals("String_Node_Str")) {
    try {
      ApplicationManager.acquireReadLockForApplication(applicationId);
      Application application=ApplicationManager.getApplications().getApplication(applicationId);
      if (application == null) {
        return null;
      }
      applicationBean=ObjectConverter.convertApplicationToApplicationInstanceBean(application);
      for (      ApplicationInstanceBean instanceBean : applicationBean.getApplicationInstances()) {
        addClustersInstancesToApplicationInstanceBean(instanceBean,application);
        addGroupsInstancesToApplicationInstanceBean(instanceBean,application);
      }
    }
  finally {
      ApplicationManager.releaseReadLockForApplication(applicationId);
    }
  }
  return applicationBean;
}
Program: 115598
Project: 115598
Buggy source:
/** 
 * Find out whether all the groups of a group in the same state or not
 * @param groups groups of a group/application
 * @param status the state to check in all groups
 * @return whether groups in the given state or not
 */
protected boolean getAllGroupInSameState(Map<String,Group> groups,GroupStatus status,String instanceId){
  boolean groupStat=false;
  for (  Group group : groups.values()) {
    GroupInstance context=group.getInstanceContexts(instanceId);
    if (context != null) {
      if (context.getStatus() == status) {
        groupStat=true;
      }
 else {
        return false;
      }
    }
 else {
      List<Instance> contexts=group.getInstanceContextsWithParentId(instanceId);
      if (contexts == null || contexts.isEmpty() && status == GroupStatus.Terminated) {
        groupStat=true;
      }
 else {
        int minGroupInstances=group.getGroupMinInstances();
        int sameStateInstances=0;
        for (        Instance context1 : contexts) {
          if (((GroupInstance)context1).getStatus().equals(status)) {
            sameStateInstances++;
          }
        }
        if (sameStateInstances >= minGroupInstances) {
          groupStat=true;
        }
 else {
          return false;
        }
      }
    }
  }
  return groupStat;
}

Fixed version (ground truth):
/** 
 * Find out whether all the groups of a group in the same state or not
 * @param groups groups of a group/application
 * @param status the state to check in all groups
 * @return whether groups in the given state or not
 */
protected boolean getAllGroupInSameState(Map<String,Group> groups,GroupStatus status,String instanceId){
  boolean groupStat=false;
  for (  Group group : groups.values()) {
    GroupInstance context=group.getInstanceContexts(instanceId);
    if (context != null) {
      if (context.getStatus() == status) {
        groupStat=true;
      }
 else {
        return false;
      }
    }
 else {
      List<Instance> contexts=group.getInstanceContextsWithParentId(instanceId);
      if (contexts == null || contexts.isEmpty() && status == GroupStatus.Terminated) {
        groupStat=true;
      }
 else {
        int sameStateInstances=0;
        for (        Instance context1 : contexts) {
          if (((GroupInstance)context1).getStatus().equals(status)) {
            sameStateInstances++;
          }
        }
        if (sameStateInstances == contexts.size()) {
          groupStat=true;
        }
 else {
          return false;
        }
      }
    }
  }
  return groupStat;
}
Program: 115599
Project: 115599
Buggy source:
protected void deactivate(ComponentContext context){
  if (asTopologyReceiver != null) {
    try {
      asTopologyReceiver.terminate();
    }
 catch (    Exception e) {
      log.warn("String_Node_Str",e);
    }
  }
  if (autoscalerHealthStatEventReceiver != null) {
    try {
      autoscalerHealthStatEventReceiver.terminate();
    }
 catch (    Exception e) {
      log.warn("String_Node_Str",e);
    }
  }
  shutdownExecutorService(AutoscalerConstants.AUTOSCALER_THREAD_POOL_ID);
  shutdownScheduledExecutorService(AutoscalerConstants.AUTOSCALER_SCHEDULER_ID);
  shutdownExecutorService(AutoscalerConstants.APPLICATION_MONITOR_THREAD_POOL_ID);
  shutdownExecutorService(AutoscalerConstants.GROUP_MONITOR_THREAD_POOL_ID);
  shutdownScheduledExecutorService(AutoscalerConstants.CLUSTER_MONITOR_SCHEDULER_ID);
  shutdownExecutorService(AutoscalerConstants.CLUSTER_MONITOR_THREAD_POOL_ID);
}

Fixed version (ground truth):
protected void deactivate(ComponentContext context){
  if (asTopologyReceiver != null) {
    try {
      asTopologyReceiver.terminate();
    }
 catch (    Exception e) {
      log.warn("String_Node_Str",e);
    }
  }
  if (autoscalerHealthStatEventReceiver != null) {
    try {
      autoscalerHealthStatEventReceiver.terminate();
    }
 catch (    Exception e) {
      log.warn("String_Node_Str",e);
    }
  }
  shutdownExecutorService(AutoscalerConstants.AUTOSCALER_THREAD_POOL_ID);
  shutdownScheduledExecutorService(AutoscalerConstants.AUTOSCALER_SCHEDULER_ID);
  shutdownExecutorService(AutoscalerConstants.MONITOR_THREAD_POOL_ID);
  shutdownScheduledExecutorService(AutoscalerConstants.CLUSTER_MONITOR_SCHEDULER_ID);
}
Program: 115602
Project: 115602
Buggy source:
public ClusterMonitor(Cluster cluster,boolean hasScalingDependents,boolean groupScalingEnabledSubtree,String deploymentPolicyId){
  scheduler=StratosThreadPool.getScheduledExecutorService(AutoscalerConstants.CLUSTER_MONITOR_SCHEDULER_ID,50);
  int threadPoolSize=Integer.getInteger(AutoscalerConstants.CLUSTER_MONITOR_THREAD_POOL_SIZE,50);
  executorService=StratosThreadPool.getExecutorService(AutoscalerConstants.CLUSTER_MONITOR_THREAD_POOL_ID,threadPoolSize);
  this.clusterId=cluster.getClusterId();
  readConfigurations();
  this.groupScalingEnabledSubtree=groupScalingEnabledSubtree;
  this.setCluster(new Cluster(cluster));
  this.serviceType=cluster.getServiceName();
  this.monitoringStarted=new AtomicBoolean(false);
  this.hasScalingDependents=hasScalingDependents;
  this.deploymentPolicyId=deploymentPolicyId;
}

Fixed version (ground truth):
public ClusterMonitor(Cluster cluster,boolean hasScalingDependents,boolean groupScalingEnabledSubtree,String deploymentPolicyId){
  scheduler=StratosThreadPool.getScheduledExecutorService(AutoscalerConstants.CLUSTER_MONITOR_SCHEDULER_ID,50);
  int threadPoolSize=Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_SIZE,100);
  executorService=StratosThreadPool.getExecutorService(AutoscalerConstants.MONITOR_THREAD_POOL_ID,threadPoolSize);
  this.clusterId=cluster.getClusterId();
  readConfigurations();
  this.groupScalingEnabledSubtree=groupScalingEnabledSubtree;
  this.setCluster(new Cluster(cluster));
  this.serviceType=cluster.getServiceName();
  this.monitoringStarted=new AtomicBoolean(false);
  this.hasScalingDependents=hasScalingDependents;
  this.deploymentPolicyId=deploymentPolicyId;
}
Program: 115604
Project: 115604
Buggy source:
public ApplicationMonitor(Application application) throws DependencyBuilderException, TopologyInConsistentException {
  super(application);
  int threadPoolSize=Integer.getInteger(AutoscalerConstants.APPLICATION_MONITOR_THREAD_POOL_SIZE,20);
  this.executorService=StratosThreadPool.getExecutorService(AutoscalerConstants.APPLICATION_MONITOR_THREAD_POOL_ID,threadPoolSize);
  this.appId=application.getUniqueIdentifier();
}

Fixed version (ground truth):
public ApplicationMonitor(Application application) throws DependencyBuilderException, TopologyInConsistentException {
  super(application);
  int threadPoolSize=Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_ID,100);
  this.executorService=StratosThreadPool.getExecutorService(AutoscalerConstants.MONITOR_THREAD_POOL_ID,threadPoolSize);
  this.appId=application.getUniqueIdentifier();
}
Program: 115605
Project: 115605
Buggy source:
/** 
 * Constructor of GroupMonitor
 * @param group Takes the group from the Topology
 * @throws DependencyBuilderException    throws when couldn't build the Topology
 * @throws TopologyInConsistentException throws when topology is inconsistent
 */
public GroupMonitor(Group group,String appId,List<String> parentInstanceId,boolean hasScalingDependents) throws DependencyBuilderException, TopologyInConsistentException {
  super(group);
  int threadPoolSize=Integer.getInteger(AutoscalerConstants.GROUP_MONITOR_THREAD_POOL_SIZE,20);
  this.executorService=StratosThreadPool.getExecutorService(AutoscalerConstants.GROUP_MONITOR_THREAD_POOL_ID,threadPoolSize);
  this.groupScalingEnabled=group.isGroupScalingEnabled();
  this.appId=appId;
  this.hasScalingDependents=hasScalingDependents;
}

Fixed version (ground truth):
/** 
 * Constructor of GroupMonitor
 * @param group Takes the group from the Topology
 * @throws DependencyBuilderException    throws when couldn't build the Topology
 * @throws TopologyInConsistentException throws when topology is inconsistent
 */
public GroupMonitor(Group group,String appId,List<String> parentInstanceId,boolean hasScalingDependents) throws DependencyBuilderException, TopologyInConsistentException {
  super(group);
  int threadPoolSize=Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_SIZE,100);
  this.executorService=StratosThreadPool.getExecutorService(AutoscalerConstants.MONITOR_THREAD_POOL_ID,threadPoolSize);
  this.groupScalingEnabled=group.isGroupScalingEnabled();
  this.appId=appId;
  this.hasScalingDependents=hasScalingDependents;
}
Program: 115607
Project: 115607
Buggy source:
public static void notifyChildren(ParentComponentMonitor componentMonitor,ScalingEvent scalingEvent){
  for (  Monitor activeChildMonitor : componentMonitor.getAliasToActiveChildMonitorsMap().values()) {
    activeChildMonitor.onParentScalingEvent(scalingEvent);
  }
}

Fixed version (ground truth):
public static void notifyChildren(ParentComponentMonitor componentMonitor,MonitorStatusEvent statusEvent) throws MonitorNotFoundException {
  for (  Monitor activeChildMonitor : componentMonitor.getAliasToActiveChildMonitorsMap().values()) {
    activeChildMonitor.onParentStatusEvent(statusEvent);
  }
}
Program: 115608
Project: 115608
Buggy source:
/** 
 * Get executed to see whether to start a new instance or not, when one of the child instance is terminated
 * @param childId    child-id of the terminated instance
 * @param instanceId instance-id of the terminated instance
 */
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);
  }
}

Fixed version (ground truth):
/** 
 * Get executed to see whether to start a new instance or not, when one of the child instance is terminated
 * @param childId    child-id of the terminated instance
 * @param instanceId instance-id of the terminated instance
 */
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"+ appId+ "String_Node_Str"+ "String_Node_Str"+ childId);
      }
    }
  }
 else {
    log.warn("String_Node_Str" + instanceId + "String_Node_Str"+ appId+ "String_Node_Str"+ id+ "String_Node_Str"+ childId);
  }
}
Program: 115611
Project: 115611
Buggy source:
@Override public void destroy(){
  for (  ClusterLevelNetworkPartitionContext networkPartitionContext : getNetworkPartitionCtxts()) {
    Collection<InstanceContext> clusterInstanceContexts=networkPartitionContext.getInstanceIdToInstanceContextMap().values();
    for (    final InstanceContext pInstanceContext : clusterInstanceContexts) {
      ClusterInstanceContext instanceContext=(ClusterInstanceContext)pInstanceContext;
      instanceContext.getMinCheckKnowledgeSession().dispose();
      instanceContext.getObsoleteCheckKnowledgeSession().dispose();
      instanceContext.getScaleCheckKnowledgeSession().dispose();
    }
  }
  setDestroyed(true);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + this.toString());
  }
}

Fixed version (ground truth):
@Override public void destroy(){
  schedulerFuture.cancel(true);
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + this.toString());
  }
}
Program: 115612
Project: 115612
Buggy source:
public void startScheduler(){
  scheduler.scheduleAtFixedRate(this,0,getMonitorIntervalMilliseconds(),TimeUnit.MILLISECONDS);
}

Fixed version (ground truth):
public void startScheduler(){
  schedulerFuture=scheduler.scheduleAtFixedRate(this,0,getMonitorIntervalMilliseconds(),TimeUnit.MILLISECONDS);
}
Program: 115614
Project: 115614
Buggy source:
/** 
 * Create a new group instance upon scale-up
 * @param networkPartitionContext the network-partition used for the instances
 * @param parentInstanceId        the parent instance id
 */
private void createGroupInstanceOnScaling(final NetworkPartitionContext networkPartitionContext,final String parentInstanceId){
  if (groupScalingEnabled) {
    if (((ParentLevelNetworkPartitionContext)networkPartitionContext).getPendingInstancesCount(parentInstanceId) == 0) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + id + "String_Node_Str"+ "String_Node_Str");
      }
      boolean createOnDemand=createInstanceOnDemand(parentInstanceId);
      if (!createOnDemand) {
        Runnable sendScaleMaxOut=new Runnable(){
          @Override public void run(){
            MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),parentInstanceId,appId);
          }
        }
;
        executorService.execute(sendScaleMaxOut);
      }
    }
 else {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + "String_Node_Str");
      }
    }
  }
 else {
    Runnable sendScaleMaxOut=new Runnable(){
      @Override public void run(){
        MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),parentInstanceId,appId);
      }
    }
;
    executorService.execute(sendScaleMaxOut);
  }
}

Fixed version (ground truth):
/** 
 * Create a new group instance upon scale-up
 * @param networkPartitionContext the network-partition used for the instances
 * @param parentInstanceId        the parent instance id
 */
private void createGroupInstanceOnScaling(final NetworkPartitionContext networkPartitionContext,final String parentInstanceId){
  if (groupScalingEnabled) {
    if (((ParentLevelNetworkPartitionContext)networkPartitionContext).getPendingInstancesCount(parentInstanceId) == 0) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + appId + "String_Node_Str"+ id+ "String_Node_Str");
      }
      boolean createOnDemand=createInstanceOnDemand(parentInstanceId);
      if (!createOnDemand) {
        Runnable sendScaleMaxOut=new Runnable(){
          @Override public void run(){
            MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),parentInstanceId,appId);
          }
        }
;
        executorService.execute(sendScaleMaxOut);
      }
    }
 else {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + "String_Node_Str");
      }
    }
  }
 else {
    Runnable sendScaleMaxOut=new Runnable(){
      @Override public void run(){
        MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),parentInstanceId,appId);
      }
    }
;
    executorService.execute(sendScaleMaxOut);
  }
}
Program: 115616
Project: 115616
Buggy source:
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent) throws MonitorNotFoundException {
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    GroupInstance instance=(GroupInstance)this.instanceIdToInstanceMap.get(instanceId);
    if (instance != null) {
      if (log.isInfoEnabled()) {
        log.info(String.format("String_Node_Str" + "String_Node_Str",appId,id,instanceId));
      }
      ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId);
    }
 else {
      List<String> instanceIds=this.getInstancesByParentInstanceId(instanceId);
      if (!instanceIds.isEmpty()) {
        for (        String instanceId1 : instanceIds) {
          if (log.isInfoEnabled()) {
            log.info(String.format("String_Node_Str" + "String_Node_Str",appId,id,instanceId1));
          }
          ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId1);
        }
      }
    }
  }
 else   if (statusEvent.getStatus() == ClusterStatus.Created || statusEvent.getStatus() == GroupStatus.Created) {
    createInstanceOnDemand(statusEvent.getInstanceId());
  }
}

Fixed version (ground truth):
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent) throws MonitorNotFoundException {
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    GroupInstance instance=(GroupInstance)this.instanceIdToInstanceMap.get(instanceId);
    if (instance != null) {
      if (log.isInfoEnabled()) {
        log.info(String.format("String_Node_Str" + "String_Node_Str",appId,id,instanceId));
      }
      ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId);
    }
 else {
      List<String> instanceIds=this.getInstancesByParentInstanceId(instanceId);
      if (!instanceIds.isEmpty()) {
        for (        String instanceId1 : instanceIds) {
          if (log.isInfoEnabled()) {
            log.info(String.format("String_Node_Str" + "String_Node_Str",appId,id,instanceId1));
          }
          ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId1);
        }
      }
    }
  }
 else   if (statusEvent.getStatus() == ClusterStatus.Created || statusEvent.getStatus() == GroupStatus.Created) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + appId + "String_Node_Str"+ id+ "String_Node_Str");
    }
    createInstanceOnDemand(statusEvent.getInstanceId());
  }
}
Program: 115618
Project: 115618
Buggy source:
@Override public void onChildScalingOverMaxEvent(ScalingUpBeyondMaxEvent scalingUpBeyondMaxEvent){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + this.getId() + "String_Node_Str"+ scalingUpBeyondMaxEvent.getNetworkPartitionId()+ "String_Node_Str"+ scalingUpBeyondMaxEvent.getId()+ "String_Node_Str"+ "String_Node_Str"+ scalingUpBeyondMaxEvent.getInstanceId());
  }
  String networkPartitionId=scalingUpBeyondMaxEvent.getNetworkPartitionId();
  String instanceId=scalingUpBeyondMaxEvent.getInstanceId();
  String id=scalingUpBeyondMaxEvent.getId();
  NetworkPartitionContext networkPartitionContext=this.getNetworkPartitionContextsMap().get(networkPartitionId);
  if (networkPartitionContext != null) {
    InstanceContext instanceContext=networkPartitionContext.getInstanceContext(instanceId);
    if (instanceContext != null) {
      if (instanceContext.containsScalingEvent(id)) {
        instanceContext.removeScalingOverMaxEvent(id);
        instanceContext.addScalingOverMaxEvent(scalingUpBeyondMaxEvent);
      }
 else {
        instanceContext.addScalingOverMaxEvent(scalingUpBeyondMaxEvent);
      }
    }
  }
  this.monitor();
}

Fixed version (ground truth):
@Override public void onChildScalingOverMaxEvent(ScalingUpBeyondMaxEvent scalingUpBeyondMaxEvent){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + this.getId() + "String_Node_Str"+ scalingUpBeyondMaxEvent.getNetworkPartitionId()+ "String_Node_Str"+ scalingUpBeyondMaxEvent.getId()+ "String_Node_Str"+ "String_Node_Str"+ scalingUpBeyondMaxEvent.getInstanceId());
  }
  String networkPartitionId=scalingUpBeyondMaxEvent.getNetworkPartitionId();
  String instanceId=scalingUpBeyondMaxEvent.getInstanceId();
  String id=scalingUpBeyondMaxEvent.getId();
  NetworkPartitionContext networkPartitionContext=this.getNetworkPartitionContextsMap().get(networkPartitionId);
  if (networkPartitionContext != null) {
    InstanceContext instanceContext=networkPartitionContext.getInstanceContext(instanceId);
    if (instanceContext != null) {
      if (instanceContext.containsScalingEvent(id)) {
        instanceContext.removeScalingOverMaxEvent(id);
        instanceContext.addScalingOverMaxEvent(scalingUpBeyondMaxEvent);
      }
 else {
        instanceContext.addScalingOverMaxEvent(scalingUpBeyondMaxEvent);
      }
    }
  }
}
Program: 115619
Project: 115619
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){
  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" + childId + "String_Node_Str"+ appId+ "String_Node_Str"+ getMonitorType()+ "String_Node_Str"+ id);
  }
}

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)) {
    Monitor childMonitor=aliasToActiveChildMonitorsMap.get(childId);
    if (childMonitor != null) {
      Instance instance=childMonitor.getInstance(instanceId);
      boolean firstIteration=false;
      if (instance != null) {
        if (instance instanceof GroupInstance) {
          GroupInstance groupInstance=(GroupInstance)instance;
          firstIteration=groupInstance.getPreviousState() == GroupStatus.Created;
        }
 else         if (instance instanceof ClusterInstance) {
          ClusterInstance clusterInstance=(ClusterInstance)instance;
          firstIteration=clusterInstance.getPreviousState() == ClusterStatus.Created;
        }
        if (firstIteration || childMonitor.hasStartupDependents()) {
          startDep=startDependency(childId,instanceId);
        }
      }
 else {
        startDep=startDependency(childId,instanceId);
      }
    }
 else {
      startDep=startDependency(childId,instanceId);
    }
  }
  if (!startDep) {
    ServiceReferenceHolder.getInstance().getGroupStatusProcessorChain().process(this.id,this.appId,instanceId);
  }
 else {
    log.info("String_Node_Str" + childId + "String_Node_Str"+ appId+ "String_Node_Str"+ getMonitorType()+ "String_Node_Str"+ id);
  }
}
Program: 115620
Project: 115620
Buggy source:
public static NetworkPartitionBean convertCCStubNetworkPartitionToNetworkPartition(org.apache.stratos.cloud.controller.stub.domain.NetworkPartition stubNetworkPartition){
  if (stubNetworkPartition == null) {
    return null;
  }
  NetworkPartitionBean networkPartition=new NetworkPartitionBean();
  networkPartition.setId(stubNetworkPartition.getId());
  if (stubNetworkPartition.getPartitions() != null) {
    List<PartitionBean> partitionList=new ArrayList<PartitionBean>();
    for (    org.apache.stratos.cloud.controller.stub.domain.Partition stubPartition : stubNetworkPartition.getPartitions()) {
      if (stubPartition != null) {
        partitionList.add(convertCCStubPartitionToPartition(stubPartition));
      }
    }
    networkPartition.setPartitions(partitionList);
  }
  if (stubNetworkPartition.getProperties() != null) {
    List<org.apache.stratos.common.beans.PropertyBean> propertyBeanList=new ArrayList<org.apache.stratos.common.beans.PropertyBean>();
    if (stubNetworkPartition.getProperties() != null) {
      if (stubNetworkPartition.getProperties().getProperties() != null) {
        for (        org.apache.stratos.cloud.controller.stub.Property stubProperty : stubNetworkPartition.getProperties().getProperties()) {
          if (stubProperty != null) {
            propertyBeanList.add(convertStubPropertyToPropertyBean(stubProperty));
          }
        }
      }
    }
    networkPartition.setProperties(propertyBeanList);
  }
  return networkPartition;
}

Fixed version (ground truth):
public static NetworkPartitionBean convertCCStubNetworkPartitionToNetworkPartition(org.apache.stratos.cloud.controller.stub.domain.NetworkPartition stubNetworkPartition){
  if (stubNetworkPartition == null) {
    return null;
  }
  NetworkPartitionBean networkPartition=new NetworkPartitionBean();
  networkPartition.setId(stubNetworkPartition.getId());
  networkPartition.setProvider(stubNetworkPartition.getProvider());
  if (stubNetworkPartition.getPartitions() != null) {
    List<PartitionBean> partitionList=new ArrayList<PartitionBean>();
    for (    org.apache.stratos.cloud.controller.stub.domain.Partition stubPartition : stubNetworkPartition.getPartitions()) {
      if (stubPartition != null) {
        partitionList.add(convertCCStubPartitionToPartition(stubPartition));
      }
    }
    networkPartition.setPartitions(partitionList);
  }
  if (stubNetworkPartition.getProperties() != null) {
    List<org.apache.stratos.common.beans.PropertyBean> propertyBeanList=new ArrayList<org.apache.stratos.common.beans.PropertyBean>();
    if (stubNetworkPartition.getProperties() != null) {
      if (stubNetworkPartition.getProperties().getProperties() != null) {
        for (        org.apache.stratos.cloud.controller.stub.Property stubProperty : stubNetworkPartition.getProperties().getProperties()) {
          if (stubProperty != null) {
            propertyBeanList.add(convertStubPropertyToPropertyBean(stubProperty));
          }
        }
      }
    }
    networkPartition.setProperties(propertyBeanList);
  }
  return networkPartition;
}
Program: 115622
Project: 115622
Buggy source:
/** 
 * Remove network partition
 * @param networkPartitionId
 * @throws NetworkPartitionNotExistsException
 */
public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException ;

Fixed version (ground truth):
/** 
 * Remove network partition
 * @param networkPartitionId
 * @throws NetworkPartitionNotExistsException
 */
public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException, InvalidNetworkPartitionException ;
Program: 115623
Project: 115623
Buggy source:
@Override public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException {
  try {
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",networkPartitionId));
    }
    handleNullObject(networkPartitionId,"String_Node_Str");
    if (cloudControllerContext.getNetworkPartition(networkPartitionId) == null) {
      String message="String_Node_Str" + networkPartitionId;
      log.error(message);
      throw new NetworkPartitionNotExistsException(message);
    }
    CloudControllerContext.getInstance().removeNetworkPartition(networkPartitionId);
    CloudControllerContext.getInstance().persist();
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",networkPartitionId));
    }
  }
 catch (  Exception e) {
    String message=e.getMessage();
    log.error(message);
    throw new CloudControllerException(message,e);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException, InvalidNetworkPartitionException {
  try {
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",networkPartitionId));
    }
    handleNullObject(networkPartitionId,"String_Node_Str");
    if (cloudControllerContext.getNetworkPartition(networkPartitionId) == null) {
      String message="String_Node_Str" + networkPartitionId;
      log.error(message);
      throw new NetworkPartitionNotExistsException(message);
    }
    validateNetworkPartition(networkPartitionId);
    CloudControllerContext.getInstance().removeNetworkPartition(networkPartitionId);
    CloudControllerContext.getInstance().persist();
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",networkPartitionId));
    }
  }
 catch (  Exception e) {
    String message=e.getMessage();
    log.error(message);
    throw new CloudControllerException(message,e);
  }
  return true;
}
Program: 115624
Project: 115624
Buggy source:
public void removeNetworkPartition(String networkPartitionId) throws RemoteException, CloudControllerServiceNetworkPartitionNotExistsExceptionException {
  stub.removeNetworkPartition(networkPartitionId);
}

Fixed version (ground truth):
public void removeNetworkPartition(String networkPartitionId) throws RemoteException, CloudControllerServiceNetworkPartitionNotExistsExceptionException, CloudControllerServiceInvalidNetworkPartitionExceptionException {
  stub.removeNetworkPartition(networkPartitionId);
}
Program: 115625
Project: 115625
Buggy source:
/** 
 * Remove network partition by network partition id
 * @return 200 if specified network partition is successfully deleted, 404 if specified network partition is notfound
 * @throws RestAPIException
 */
@DELETE @Path("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response removeNetworkPartition(@PathParam("String_Node_Str") String networkPartitionId) throws RestAPIException {
  try {
    StratosApiV41Utils.removeNetworkPartition(networkPartitionId);
  }
 catch (  CloudControllerServiceNetworkPartitionNotExistsExceptionException e) {
    return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,"String_Node_Str")).build();
  }
  return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,String.format("String_Node_Str",networkPartitionId))).build();
}

Fixed version (ground truth):
/** 
 * Remove network partition by network partition id
 * @return 200 if specified network partition is successfully deleted, 404 if specified network partition is notfound
 * @throws RestAPIException
 */
@DELETE @Path("String_Node_Str") @AuthorizationAction("String_Node_Str") public Response removeNetworkPartition(@PathParam("String_Node_Str") String networkPartitionId) throws RestAPIException {
  try {
    StratosApiV41Utils.removeNetworkPartition(networkPartitionId);
  }
 catch (  CloudControllerServiceNetworkPartitionNotExistsExceptionException e) {
    return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,"String_Node_Str")).build();
  }
catch (  CloudControllerServiceInvalidNetworkPartitionExceptionException e) {
    return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(ResponseMessageBean.ERROR,"String_Node_Str")).build();
  }
  return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,String.format("String_Node_Str",networkPartitionId))).build();
}
Program: 115627
Project: 115627
Buggy source:
@Override public void setDynamicPayload(byte[] payload){
  IaasProvider iaasInfo=getIaasProvider();
  if (iaasInfo.getTemplate() == null || iaasInfo.getPayload() == null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str");
    }
    return;
  }
  String payloadStr=new String(payload);
  log.info("String_Node_Str" + payloadStr);
  Map<String,String> keyValuePairTagsMap=new HashMap<String,String>();
  keyValuePairTagsMap.put("String_Node_Str",payloadStr);
  iaasInfo.getTemplate().getOptions().userMetadata(keyValuePairTagsMap);
}

Fixed version (ground truth):
@Override public void setDynamicPayload(byte[] payload){
  IaasProvider iaasInfo=getIaasProvider();
  if (iaasInfo.getTemplate() == null || payload == null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str");
    }
    return;
  }
  String payloadStr=new String(payload);
  log.info("String_Node_Str" + payloadStr);
  Map<String,String> keyValuePairTagsMap=new HashMap<String,String>();
  keyValuePairTagsMap.put("String_Node_Str",payloadStr);
  iaasInfo.getTemplate().getOptions().userMetadata(keyValuePairTagsMap);
}
Program: 115629
Project: 115629
Buggy source:
public void initializeTopology(){
  if (initialized) {
    return;
  }
  try {
    boolean membersFound=false;
    TopologyManager.acquireReadLock();
    for (    Service service : TopologyManager.getTopology().getServices()) {
      for (      Cluster cluster : service.getClusters()) {
        for (        Member member : cluster.getMembers()) {
          if (member.getStatus() == MemberStatus.Active) {
            addMember(cluster.getServiceName(),member.getClusterId(),member.getMemberId());
            membersFound=true;
          }
        }
      }
    }
    if (membersFound) {
      initialized=true;
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
 finally {
    TopologyManager.releaseReadLock();
  }
}

Fixed version (ground truth):
public void initializeTopology(){
  if (initialized) {
    return;
  }
  try {
    boolean membersFound=false;
    TopologyManager.acquireReadLock();
    for (    Service service : TopologyManager.getTopology().getServices()) {
      for (      Cluster cluster : service.getClusters()) {
        for (        Member member : cluster.getMembers()) {
          if (member.getStatus() == MemberStatus.Active) {
            String serviceName=member.getServiceName();
            String clusterId=member.getClusterId();
            String memberId=member.getMemberId();
            String networkPartitionIdFilter=System.getProperty("String_Node_Str").trim();
            if (!networkPartitionIdFilter.equals("String_Node_Str")) {
              if (member.getNetworkPartitionId().equals(networkPartitionIdFilter)) {
                addMember(serviceName,clusterId,memberId);
                membersFound=true;
              }
            }
 else {
              addMember(serviceName,clusterId,memberId);
              membersFound=true;
            }
          }
        }
      }
    }
    if (membersFound) {
      initialized=true;
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
 finally {
    TopologyManager.releaseReadLock();
  }
}