nus-yam/ex-repair huggingface dataset:
Program: 116064
Project: 116064
Buggy source:
public static void handleGroupInactivateEvent(String appId,String groupId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupInstance context=group.getInstanceContexts(instanceId);
  GroupStatus status=GroupStatus.Inactive;
  if (context != null) {
    if (context.isStateTransitionValid(status)) {
      context.setStatus(status);
      updateGroupMonitor(appId,groupId,status,instanceId);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendGroupInstanceInactivateEvent(appId,groupId,instanceId);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId+ "String_Node_Str"+ context.getStatus()+ "String_Node_Str"+ status);
    }
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
  }
}

Fixed version (ground truth):
public static void handleGroupInactivateEvent(String appId,String groupId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupInstance groupInstance=group.getInstanceContexts(instanceId);
  GroupStatus status=GroupStatus.Inactive;
  if (groupInstance != null) {
    if (groupInstance.isStateTransitionValid(status)) {
      groupInstance.setStatus(status);
      updateGroupMonitor(appId,groupId,status,instanceId,groupInstance.getParentId());
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendGroupInstanceInactivateEvent(appId,groupId,instanceId);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId+ "String_Node_Str"+ groupInstance.getStatus()+ "String_Node_Str"+ status);
    }
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
  }
}
Program: 116066
Project: 116066
Buggy source:
public static void handleApplicationInstanceInactivateEvent(String appId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId + "String_Node_Str"+ instanceId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  ApplicationStatus status=ApplicationStatus.Inactive;
  ApplicationInstance context=application.getInstanceContexts(instanceId);
  if (context.isStateTransitionValid(status)) {
    application.setStatus(status,instanceId);
    updateApplicationMonitor(appId,status,instanceId);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendApplicationInstanceInactivatedEvent(appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,instanceId,context.getStatus(),status));
  }
}

Fixed version (ground truth):
public static void handleApplicationInstanceInactivateEvent(String appId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId + "String_Node_Str"+ instanceId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  ApplicationStatus status=ApplicationStatus.Inactive;
  ApplicationInstance applicationInstance=application.getInstanceContexts(instanceId);
  if (applicationInstance.isStateTransitionValid(status)) {
    application.setStatus(status,instanceId);
    updateApplicationMonitor(appId,status,instanceId);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendApplicationInstanceInactivatedEvent(appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,instanceId,applicationInstance.getStatus(),status));
  }
}
Program: 116067
Project: 116067
Buggy source:
private static void updateGroupMonitor(String appId,String groupId,GroupStatus status,String instanceId){
  GroupMonitor monitor=getGroupMonitor(appId,groupId);
  if (monitor != null) {
    monitor.setStatus(status,instanceId);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
}

Fixed version (ground truth):
private static void updateGroupMonitor(String appId,String groupId,GroupStatus status,String instanceId,String parentInstanceId){
  GroupMonitor monitor=getGroupMonitor(appId,groupId);
  if (monitor != null) {
    monitor.setStatus(status,instanceId,parentInstanceId);
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ appId);
  }
}
Program: 116068
Project: 116068
Buggy source:
public static void handleGroupInstanceActivatedEvent(String appId,String groupId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId+ "String_Node_Str"+ instanceId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupInstance context=group.getInstanceContexts(instanceId);
  GroupStatus status=GroupStatus.Active;
  if (context != null) {
    if (context.isStateTransitionValid(status)) {
      context.setStatus(status);
      updateGroupMonitor(appId,groupId,status,instanceId);
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendGroupInstanceActivatedEvent(appId,groupId,instanceId);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId+ "String_Node_Str"+ context.getStatus()+ "String_Node_Str"+ status);
    }
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
  }
}

Fixed version (ground truth):
public static void handleGroupInstanceActivatedEvent(String appId,String groupId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + groupId + "String_Node_Str"+ appId+ "String_Node_Str"+ instanceId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  Group group=application.getGroupRecursively(groupId);
  if (group == null) {
    log.warn(String.format("String_Node_Str",groupId));
    return;
  }
  GroupInstance groupInstance=group.getInstanceContexts(instanceId);
  GroupStatus status=GroupStatus.Active;
  if (groupInstance != null) {
    if (groupInstance.isStateTransitionValid(status)) {
      groupInstance.setStatus(status);
      updateGroupMonitor(appId,groupId,status,instanceId,groupInstance.getParentId());
      ApplicationHolder.persistApplication(application);
      ApplicationsEventPublisher.sendGroupInstanceActivatedEvent(appId,groupId,instanceId);
    }
 else {
      log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId+ "String_Node_Str"+ groupInstance.getStatus()+ "String_Node_Str"+ status);
    }
  }
 else {
    log.warn("String_Node_Str" + groupId + "String_Node_Str"+ instanceId);
  }
}
Program: 116069
Project: 116069
Buggy source:
public static void handleApplicationInstanceActivatedEvent(String appId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId + "String_Node_Str"+ instanceId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  ApplicationStatus status=ApplicationStatus.Active;
  ApplicationInstance context=application.getInstanceContexts(instanceId);
  if (context.isStateTransitionValid(status)) {
    application.setStatus(status,instanceId);
    updateApplicationMonitor(appId,status,instanceId);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendApplicationInstanceActivatedEvent(appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,instanceId,context.getStatus(),status));
  }
}

Fixed version (ground truth):
public static void handleApplicationInstanceActivatedEvent(String appId,String instanceId){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + appId + "String_Node_Str"+ instanceId);
  }
  Applications applications=ApplicationHolder.getApplications();
  Application application=applications.getApplication(appId);
  if (application == null) {
    log.warn(String.format("String_Node_Str",appId));
    return;
  }
  ApplicationStatus status=ApplicationStatus.Active;
  ApplicationInstance applicationInstance=application.getInstanceContexts(instanceId);
  if (applicationInstance.isStateTransitionValid(status)) {
    application.setStatus(status,instanceId);
    updateApplicationMonitor(appId,status,instanceId);
    ApplicationHolder.persistApplication(application);
    ApplicationsEventPublisher.sendApplicationInstanceActivatedEvent(appId,instanceId);
  }
 else {
    log.warn(String.format("String_Node_Str" + "String_Node_Str",appId,instanceId,applicationInstance.getStatus(),status));
  }
}
Program: 116070
Project: 116070
Buggy source:
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent){
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + appId + "String_Node_Str"+ this.getClusterId());
    }
    ClusterStatusEventPublisher.sendClusterTerminatingEvent(getAppId(),getServiceId(),getClusterId(),instanceId);
  }
}

Fixed version (ground truth):
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent){
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + appId + "String_Node_Str"+ this.getClusterId()+ "String_Node_Str"+ instanceId);
    }
    ClusterStatusEventPublisher.sendClusterTerminatingEvent(getAppId(),getServiceId(),getClusterId(),instanceId);
  }
}
Program: 116071
Project: 116071
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) {
      ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId);
    }
 else {
      List<String> instanceIds=this.getInstancesByParentInstanceId(instanceId);
      if (!instanceIds.isEmpty()) {
        for (        String instanceId1 : instanceIds) {
          ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId1);
        }
      }
    }
  }
 else   if (statusEvent.getStatus() == ClusterStatus.Created || statusEvent.getStatus() == GroupStatus.Created) {
    Application application=ApplicationHolder.getApplications().getApplication(this.appId);
    Group group=application.getGroupRecursively(statusEvent.getId());
    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_Node_Str" + appId + "String_Node_Str"+ id+ "String_Node_Str"+ 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_Node_Str" + appId + "String_Node_Str"+ id+ "String_Node_Str"+ instanceId1);
          }
          ApplicationBuilder.handleGroupTerminatingEvent(appId,id,instanceId1);
        }
      }
    }
  }
 else   if (statusEvent.getStatus() == ClusterStatus.Created || statusEvent.getStatus() == GroupStatus.Created) {
    createInstanceOnDemand(statusEvent.getInstanceId());
  }
}
Program: 116073
Project: 116073
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(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) {
      boolean childTerminated=verifyGroupStatus(instanceId,(GroupStatus)status1);
      if (childTerminated) {
        onTerminationOfInstance(childId,instanceId);
      }
 else {
        log.info("String_Node_Str");
      }
    }
 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) {
    if (status1 == GroupStatus.Terminated) {
      onTerminationOfInstance(childId,instanceId);
    }
 else {
      onTerminationOfInstance(childId,instanceId);
    }
  }
}
Program: 116074
Project: 116074
Buggy source:
public boolean verifyGroupStatus(String instanceId,GroupStatus requiredStatus){
  if (this.instanceIdToInstanceMap.containsKey(instanceId)) {
    if (((GroupInstance)this.instanceIdToInstanceMap.get(instanceId)).getStatus() == requiredStatus) {
      return true;
    }
  }
 else {
    List<GroupInstance> instances=new ArrayList<GroupInstance>();
    String networkPartitionId=null;
    int noOfInstancesOfRequiredStatus=0;
    for (    Instance instance : this.instanceIdToInstanceMap.values()) {
      GroupInstance groupInstance=(GroupInstance)instance;
      if (groupInstance.getParentId().equals(instanceId)) {
        instances.add(groupInstance);
        networkPartitionId=groupInstance.getNetworkPartitionId();
        if (groupInstance.getStatus() == requiredStatus) {
          noOfInstancesOfRequiredStatus++;
        }
      }
    }
    if (!instances.isEmpty()) {
      int minInstances=this.networkPartitionCtxts.get(networkPartitionId).getMinInstanceCount();
      if (noOfInstancesOfRequiredStatus == this.inactiveInstancesMap.size() && requiredStatus == GroupStatus.Terminated) {
        return true;
      }
 else       if (noOfInstancesOfRequiredStatus >= minInstances) {
        return true;
      }
 else {
        if (requiredStatus == GroupStatus.Inactive && noOfInstancesOfRequiredStatus >= 1) {
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean verifyGroupStatus(String childId,String instanceId,GroupStatus requiredStatus){
  Monitor monitor=this.getMonitor(childId);
  List<String> groupInstances;
  GroupInstance groupInstance=(GroupInstance)monitor.getInstance(instanceId);
  if (groupInstance == null) {
    groupInstances=monitor.getInstancesByParentInstanceId(instanceId);
  }
 else {
    if (groupInstance.getStatus() == requiredStatus) {
      return true;
    }
 else {
      return false;
    }
  }
  String networkPartitionId=null;
  int noOfInstancesOfRequiredStatus=0;
  for (  String childInstanceId : groupInstances) {
    GroupInstance childGroupInstance=(GroupInstance)monitor.getInstance(childInstanceId);
    networkPartitionId=childGroupInstance.getNetworkPartitionId();
    if (childGroupInstance.getStatus() == requiredStatus) {
      noOfInstancesOfRequiredStatus++;
    }
  }
  if (!groupInstances.isEmpty()) {
    int minInstances=this.networkPartitionCtxts.get(networkPartitionId).getMinInstanceCount();
    if (noOfInstancesOfRequiredStatus == this.inactiveInstancesMap.size() && requiredStatus == GroupStatus.Terminated) {
      return true;
    }
 else     if (noOfInstancesOfRequiredStatus >= minInstances) {
      return true;
    }
 else {
      if (requiredStatus == GroupStatus.Inactive && noOfInstancesOfRequiredStatus >= 1) {
        return true;
      }
    }
  }
  return false;
}
Program: 116075
Project: 116075
Buggy source:
/** 
 * Creates the group instance and adds the required context objects
 * @param group                             the group
 * @param parentInstanceContext             the parent instance context
 * @param partitionContext
 * @param groupLevelNetworkPartitionContext the group level network partition context
 */
private String createGroupInstanceAndAddToMonitor(Group group,Instance parentInstanceContext,PartitionContext partitionContext,GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext,GroupInstance groupInstance){
  String partitionId;
  if (groupInstance == null) {
    partitionId=partitionContext.getPartitionId();
    groupInstance=createGroupInstance(group,parentInstanceContext.getNetworkPartitionId(),parentInstanceContext.getInstanceId(),partitionId);
  }
  this.addInstance(groupInstance);
  String instanceId=groupInstance.getInstanceId();
  GroupInstanceContext groupInstanceContext=new GroupInstanceContext(instanceId);
  groupInstanceContext.setParentInstanceId(groupInstance.getParentId());
  groupInstanceContext.addPartitionContext((GroupLevelPartitionContext)partitionContext);
  groupLevelNetworkPartitionContext.addInstanceContext(groupInstanceContext);
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + instanceId + "String_Node_Str"+ this.id);
  }
  if (partitionContext != null) {
    ((GroupLevelPartitionContext)partitionContext).addActiveInstance(groupInstance);
  }
  return instanceId;
}

Fixed version (ground truth):
/** 
 * Creates the group instance and adds the required context objects
 * @param group                             the group
 * @param parentInstanceContext             the parent instance context
 * @param partitionContext
 * @param groupLevelNetworkPartitionContext the group level network partition context
 */
private String createGroupInstanceAndAddToMonitor(Group group,Instance parentInstanceContext,PartitionContext partitionContext,GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext,GroupInstance groupInstance){
  String partitionId=null;
  if (groupInstance == null) {
    if (partitionContext != null) {
      partitionId=partitionContext.getPartitionId();
    }
    groupInstance=createGroupInstance(group,parentInstanceContext.getNetworkPartitionId(),parentInstanceContext.getInstanceId(),partitionId);
  }
  this.addInstance(groupInstance);
  String instanceId=groupInstance.getInstanceId();
  GroupInstanceContext groupInstanceContext=new GroupInstanceContext(instanceId);
  groupInstanceContext.setParentInstanceId(groupInstance.getParentId());
  groupInstanceContext.addPartitionContext((GroupLevelPartitionContext)partitionContext);
  groupLevelNetworkPartitionContext.addInstanceContext(groupInstanceContext);
  if (log.isInfoEnabled()) {
    log.info("String_Node_Str" + instanceId + "String_Node_Str"+ this.id);
  }
  if (partitionContext != null) {
    ((GroupLevelPartitionContext)partitionContext).addActiveInstance(groupInstance);
  }
  return instanceId;
}
Program: 116076
Project: 116076
Buggy source:
private PartitionContext getPartitionContext(GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext,String parentPartitionId){
  PartitionContext partitionContext;
  List<GroupLevelPartitionContext> partitionContexts=groupLevelNetworkPartitionContext.getPartitionCtxts();
  GroupLevelPartitionContext[] groupLevelPartitionContexts=new GroupLevelPartitionContext[partitionContexts.size()];
  if (parentPartitionId == null) {
    AutoscaleAlgorithm algorithm=this.getAutoscaleAlgorithm(groupLevelNetworkPartitionContext.getPartitionAlgorithm());
    partitionContext=algorithm.getNextScaleUpPartitionContext((partitionContexts.toArray(groupLevelPartitionContexts)));
  }
 else {
    partitionContext=groupLevelNetworkPartitionContext.getPartitionContextById(parentPartitionId);
  }
  return partitionContext;
}

Fixed version (ground truth):
private PartitionContext getPartitionContext(GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext,String parentPartitionId){
  PartitionContext partitionContext=null;
  List<GroupLevelPartitionContext> partitionContexts=groupLevelNetworkPartitionContext.getPartitionCtxts();
  GroupLevelPartitionContext[] groupLevelPartitionContexts=new GroupLevelPartitionContext[partitionContexts.size()];
  if (parentPartitionId == null) {
    if (!partitionContexts.isEmpty()) {
      AutoscaleAlgorithm algorithm=this.getAutoscaleAlgorithm(groupLevelNetworkPartitionContext.getPartitionAlgorithm());
      partitionContext=algorithm.getNextScaleUpPartitionContext((partitionContexts.toArray(groupLevelPartitionContexts)));
    }
  }
 else {
    partitionContext=groupLevelNetworkPartitionContext.getPartitionContextById(parentPartitionId);
  }
  return partitionContext;
}
Program: 116080
Project: 116080
Buggy source:
/** 
 * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
 * @param appId Application id
 * @param groupName Group name
 * @param cartridgeInfo Cartridge information
 * @param subscriptionKey Generated key for the Application
 * @param tenantId Tenant Id of the tenant which deployed the Application
 * @param repoUrl Repository URL
 * @param alias alias specified for this Subscribable in the Application Definition
 * @param clusterId Cluster id
 * @param hostname Hostname
 * @param deploymentPolicy Deployment policy used
 * @param isLB if this cluster is an LB
 * @return ApplicationClusterContext object with relevant information
 * @throws ApplicationDefinitionException If any error occurs
 */
private ApplicationClusterContext createApplicationClusterContext(String appId,String groupName,CartridgeInfo cartridgeInfo,String subscriptionKey,int tenantId,String repoUrl,String alias,String clusterId,String hostname,String deploymentPolicy,boolean isLB,String[] dependencyAliases,Properties properties) throws ApplicationDefinitionException {
  PayloadData payloadData=ApplicationUtils.createPayload(appId,groupName,cartridgeInfo,subscriptionKey,tenantId,clusterId,hostname,repoUrl,alias,null,dependencyAliases,properties);
  String oAuth_token=createToken(appId);
  payloadData.add(TOKEN_PAYLOD_PARAM_NAME,oAuth_token);
  String textPayload=payloadData.toString();
  return new ApplicationClusterContext(cartridgeInfo.getType(),clusterId,hostname,textPayload,deploymentPolicy,isLB);
}

Fixed version (ground truth):
/** 
 * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application
 * @param appId Application id
 * @param groupName Group name
 * @param cartridgeInfo Cartridge information
 * @param subscriptionKey Generated key for the Application
 * @param tenantId Tenant Id of the tenant which deployed the Application
 * @param repoUrl Repository URL
 * @param alias alias specified for this Subscribable in the Application Definition
 * @param clusterId Cluster id
 * @param hostname Hostname
 * @param deploymentPolicy Deployment policy used
 * @param isLB if this cluster is an LB
 * @return ApplicationClusterContext object with relevant information
 * @throws ApplicationDefinitionException If any error occurs
 */
private ApplicationClusterContext createApplicationClusterContext(String appId,String groupName,CartridgeInfo cartridgeInfo,String subscriptionKey,int tenantId,String repoUrl,String alias,String clusterId,String hostname,String deploymentPolicy,boolean isLB,String[] dependencyAliases,Properties properties) throws ApplicationDefinitionException {
  PayloadData payloadData=ApplicationUtils.createPayload(appId,groupName,cartridgeInfo,subscriptionKey,tenantId,clusterId,hostname,repoUrl,alias,null,dependencyAliases,properties);
  String textPayload=payloadData.toString();
  return new ApplicationClusterContext(cartridgeInfo.getType(),clusterId,hostname,textPayload,deploymentPolicy,isLB);
}
Program: 116082
Project: 116082
Buggy source:
/** 
 * This will start the parallel dependencies at once from the top level by traversing to find the terminated dependencies. it will get invoked when start a child monitor on termination of a sub tree
 */
public void startDependencyOnTermination(String instanceId) throws TopologyInConsistentException, MonitorNotFoundException, PolicyValidationException, PartitionValidationException {
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependenciesByTermination(this,instanceId);
  for (  ApplicationChildContext context : applicationContexts) {
    if (context instanceof GroupChildContext) {
      GroupMonitor groupMonitor=(GroupMonitor)this.aliasToActiveMonitorsMap.get(context.getId());
    }
 else     if (context instanceof ClusterChildContext) {
    }
  }
}

Fixed version (ground truth):
/** 
 * This will start the parallel dependencies at once from the top level by traversing to find the terminated dependencies. it will get invoked when start a child monitor on termination of a sub tree
 */
public void startDependencyOnTermination(String instanceId) throws TopologyInConsistentException, MonitorNotFoundException, PolicyValidationException, PartitionValidationException {
  List<ApplicationChildContext> applicationContexts=this.startupDependencyTree.getStarAbleDependenciesByTermination(this,instanceId);
  for (  ApplicationChildContext context : applicationContexts) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + context.getId() + "String_Node_Str");
    }
    if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) {
      String msg="String_Node_Str";
      throw new MonitorNotFoundException(msg);
    }
 else {
      Monitor monitor=aliasToActiveMonitorsMap.get(context.getId());
      monitor.createInstanceOnDemand(instanceId);
    }
  }
}
Program: 116083
Project: 116083
Buggy source:
private boolean allParentTerminated(List<ApplicationChildContext> parentContexts,String instanceId){
  boolean parentsTerminated=false;
  for (  ApplicationChildContext context1 : parentContexts) {
    if (this.inactiveInstancesMap.containsKey(context1.getId()) && this.inactiveInstancesMap.get(context1.getId()).contains(instanceId)) {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str");
      parentsTerminated=false;
      return parentsTerminated;
    }
 else     if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
      if (parentsTerminated) {
        log.warn("String_Node_Str" + context1.getId() + "String_Node_Str");
      }
    }
 else {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str");
      parentsTerminated=true;
    }
  }
  return parentsTerminated;
}

Fixed version (ground truth):
private boolean allParentTerminated(List<ApplicationChildContext> parentContexts,String instanceId){
  boolean parentsTerminated=false;
  for (  ApplicationChildContext context1 : parentContexts) {
    if (this.inactiveInstancesMap.containsKey(context1.getId()) && this.inactiveInstancesMap.get(context1.getId()).contains(instanceId) || this.terminatingInstancesMap.containsKey(context1.getId()) && this.terminatingInstancesMap.get(context1.getId()).contains(instanceId)) {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str");
      parentsTerminated=false;
      return parentsTerminated;
    }
 else     if (this.aliasToActiveMonitorsMap.get(context1.getId()).getInstance(instanceId) != null) {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str"+ instanceId+ "String_Node_Str");
    }
 else {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str");
      parentsTerminated=true;
    }
  }
  return parentsTerminated;
}
Program: 116084
Project: 116084
Buggy source:
private boolean allDependentTerminated(List<ApplicationChildContext> terminationList){
  boolean allDependentTerminated=false;
  for (  ApplicationChildContext context1 : terminationList) {
    if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
      log.warn("String_Node_Str" + context1.getId() + "String_Node_Str");
      allDependentTerminated=false;
      return allDependentTerminated;
    }
 else     if (this.inactiveInstancesMap.containsKey(context1.getId())) {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str");
      allDependentTerminated=false;
      return allDependentTerminated;
    }
 else {
      allDependentTerminated=true;
    }
  }
  return allDependentTerminated;
}

Fixed version (ground truth):
private boolean allDependentTerminated(List<ApplicationChildContext> terminationList,String instanceId){
  boolean allDependentTerminated=false;
  for (  ApplicationChildContext context1 : terminationList) {
    if (this.inactiveInstancesMap.containsKey(context1.getId()) && this.inactiveInstancesMap.get(context1.getId()).contains(instanceId) || this.terminatingInstancesMap.containsKey(context1.getId()) && this.terminatingInstancesMap.get(context1.getId()).contains(instanceId)) {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str"+ instanceId+ "String_Node_Str");
      allDependentTerminated=false;
      return allDependentTerminated;
    }
 else     if (this.aliasToActiveMonitorsMap.get(context1.getId()).getInstance(instanceId) != null) {
      log.info("String_Node_Str" + context1.getId() + "String_Node_Str"+ instanceId+ "String_Node_Str");
    }
 else {
      allDependentTerminated=true;
    }
  }
  return allDependentTerminated;
}
Program: 116086
Project: 116086
Buggy source:
/** 
 * Find out whether all the clusters of a group are in the same state
 * @param clusterData clusters of the group
 * @param status      the status to check of the group
 * @return whether all groups in the same state or not
 */
protected boolean getAllClusterInSameState(Map<String,ClusterDataHolder> clusterData,ClusterStatus status,String instanceId){
  boolean clusterStat=false;
  for (  Map.Entry<String,ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
    String serviceName=clusterDataHolderEntry.getValue().getServiceType();
    String clusterId=clusterDataHolderEntry.getValue().getClusterId();
    TopologyManager.acquireReadLockForCluster(serviceName,clusterId);
    try {
      Service service=TopologyManager.getTopology().getService(serviceName);
      Cluster cluster=service.getCluster(clusterId);
      ClusterInstance context=cluster.getInstanceContexts(instanceId);
      if (context != null) {
        if (context.getStatus() == status) {
          clusterStat=true;
        }
 else {
          clusterStat=false;
        }
      }
 else {
        if (status == ClusterStatus.Terminated) {
          clusterStat=true;
        }
 else {
          clusterStat=false;
          return clusterStat;
        }
      }
    }
  finally {
      TopologyManager.releaseReadLockForCluster(serviceName,clusterId);
    }
  }
  return clusterStat;
}

Fixed version (ground truth):
/** 
 * Find out whether all the clusters of a group are in the same state
 * @param clusterData clusters of the group
 * @param status      the status to check of the group
 * @return whether all groups in the same state or not
 */
protected boolean getAllClusterInSameState(Map<String,ClusterDataHolder> clusterData,ClusterStatus status,String instanceId){
  boolean clusterStat=false;
  for (  Map.Entry<String,ClusterDataHolder> clusterDataHolderEntry : clusterData.entrySet()) {
    String serviceName=clusterDataHolderEntry.getValue().getServiceType();
    String clusterId=clusterDataHolderEntry.getValue().getClusterId();
    TopologyManager.acquireReadLockForCluster(serviceName,clusterId);
    try {
      Service service=TopologyManager.getTopology().getService(serviceName);
      Cluster cluster=service.getCluster(clusterId);
      ClusterInstance context=cluster.getInstanceContexts(instanceId);
      if (context != null) {
        if (log.isInfoEnabled()) {
          log.info("String_Node_Str" + clusterId + "String_Node_Str"+ context.getStatus().toString());
        }
        if (context.getStatus() == status) {
          clusterStat=true;
        }
 else {
          clusterStat=false;
          return clusterStat;
        }
      }
 else {
        if (status == ClusterStatus.Terminated) {
          clusterStat=true;
        }
 else {
          clusterStat=false;
          return clusterStat;
        }
      }
    }
  finally {
      TopologyManager.releaseReadLockForCluster(serviceName,clusterId);
    }
  }
  return clusterStat;
}
Program: 116088
Project: 116088
Buggy source:
/** 
 * Find the startup order
 * @param groupContext GroupContext with Group defintion information
 * @return Set of Startup Orders which are defined in the Group
 * @throws ApplicationDefinitionException
 */
private String[] getStartupOrderForGroup(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
}

Fixed version (ground truth):
/** 
 * Find the startup order
 * @param serviceGroup GroupContext with Group defintion information
 * @return Set of Startup Orders which are defined in the Group
 * @throws ApplicationDefinitionException
 */
private String[] getStartupOrderForGroup(String serviceGroupName,ServiceGroup serviceGroup) throws ApplicationDefinitionException {
}
Program: 116093
Project: 116093
Buggy source:
private static void addClustersToApplicationBean(ApplicationBean applicationBean,Application application){
  Map<String,ClusterDataHolder> topLevelClusterDataMap=application.getClusterDataMap();
  for (  Map.Entry<String,ClusterDataHolder> entry : topLevelClusterDataMap.entrySet()) {
    ClusterDataHolder clusterDataHolder=entry.getValue();
    String clusterId=clusterDataHolder.getClusterId();
    String serviceType=clusterDataHolder.getServiceType();
    TopologyManager.acquireReadLockForCluster(serviceType,clusterId);
    Cluster topLevelCluster;
    try {
      TopologyManager.acquireReadLockForCluster(serviceType,clusterId);
      topLevelCluster=TopologyManager.getTopology().getService(serviceType).getCluster(clusterId);
    }
  finally {
      TopologyManager.releaseReadLockForCluster(serviceType,clusterId);
    }
    applicationBean.clusters.add(PojoConverter.populateClusterPojos(topLevelCluster,entry.getKey()));
  }
}

Fixed version (ground truth):
private static void addClustersToApplicationBean(ApplicationBean applicationBean,Application application){
  Map<String,ClusterDataHolder> topLevelClusterDataMap=application.getClusterDataMap();
  for (  Map.Entry<String,ClusterDataHolder> entry : topLevelClusterDataMap.entrySet()) {
    ClusterDataHolder clusterDataHolder=entry.getValue();
    String clusterId=clusterDataHolder.getClusterId();
    String serviceType=clusterDataHolder.getServiceType();
    TopologyManager.acquireReadLockForCluster(serviceType,clusterId);
    Cluster topLevelCluster=TopologyManager.getTopology().getService(serviceType).getCluster(clusterId);
    applicationBean.clusters.add(PojoConverter.populateClusterPojos(topLevelCluster,entry.getKey()));
  }
}
Program: 116094
Project: 116094
Buggy source:
public NodeMetadata createInstance(ClusterContext clusterContext,MemberContext memberContext){
synchronized (MockIaasService.class) {
    MockMemberContext mockMemberContext=new MockMemberContext(clusterContext.getCartridgeType(),clusterContext.getClusterId(),memberContext.getMemberId(),memberContext.getNetworkPartitionId(),memberContext.getPartition().getId(),memberContext.getInstanceId());
    MockMember mockMember=new MockMember(mockMemberContext);
    membersMap.put(mockMember.getMockMemberContext().getMemberId(),mockMember);
    mockMemberExecutorService.submit(mockMember);
    MockNodeMetadata nodeMetadata=new MockNodeMetadata();
    nodeMetadata.setId(UUID.randomUUID().toString());
    persistInRegistry();
    if (!MockHealthStatisticsGenerator.isScheduled()) {
      MockHealthStatisticsGenerator.scheduleStatisticsUpdaters();
    }
    return nodeMetadata;
  }
}

Fixed version (ground truth):
public NodeMetadata createInstance(ClusterContext clusterContext,MemberContext memberContext){
synchronized (MockIaasService.class) {
    MockMemberContext mockMemberContext=new MockMemberContext(clusterContext.getCartridgeType(),clusterContext.getClusterId(),memberContext.getMemberId(),memberContext.getNetworkPartitionId(),memberContext.getPartition().getId(),memberContext.getInstanceId());
    MockMember mockMember=new MockMember(mockMemberContext);
    membersMap.put(mockMember.getMockMemberContext().getMemberId(),mockMember);
    mockMemberExecutorService.submit(mockMember);
    MockNodeMetadata nodeMetadata=new MockNodeMetadata();
    nodeMetadata.setId(UUID.randomUUID().toString());
    persistInRegistry();
    if (!MockHealthStatisticsGenerator.getInstance().isScheduled()) {
      MockHealthStatisticsGenerator.getInstance().scheduleStatisticsUpdaters();
    }
    return nodeMetadata;
  }
}
Program: 116095
Project: 116095
Buggy source:
public void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException, InvalidMemberException {
synchronized (MockIaasService.class) {
    MockMember mockMember=membersMap.get(memberContext.getMemberId());
    if (mockMember != null) {
      mockMember.terminate();
      membersMap.remove(memberContext.getMemberId());
    }
    if (membersMap.size() == 0) {
      MockHealthStatisticsGenerator.stopStatisticsUpdaters();
    }
  }
}

Fixed version (ground truth):
public void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException, InvalidMemberException {
synchronized (MockIaasService.class) {
    MockMember mockMember=membersMap.get(memberContext.getMemberId());
    if (mockMember != null) {
      mockMember.terminate();
      membersMap.remove(memberContext.getMemberId());
    }
    if (membersMap.size() == 0) {
      MockHealthStatisticsGenerator.getInstance().stopStatisticsUpdaters();
    }
  }
}
Program: 116096
Project: 116096
Buggy source:
public static boolean isScheduled(){
  return scheduled;
}

Fixed version (ground truth):
public boolean isScheduled(){
  return scheduled;
}
Program: 116097
Project: 116097
Buggy source:
public static void scheduleStatisticsUpdaters(){
  if (!scheduled) {
synchronized (MockHealthStatisticsGenerator.class) {
      if (!scheduled) {
        List<MockHealthStatisticsPattern> statisticsPatterns=MockIaasConfig.getInstance().getMockHealthStatisticsConfig().getStatisticsPatterns();
        for (        MockHealthStatisticsPattern statisticsPattern : statisticsPatterns) {
          scheduledExecutorService.scheduleAtFixedRate(new MockHealthStatisticsUpdater(statisticsPattern),0,statisticsPattern.getSampleDuration(),TimeUnit.SECONDS);
        }
        if (log.isInfoEnabled()) {
          log.info("String_Node_Str");
        }
        scheduled=true;
      }
    }
  }
}

Fixed version (ground truth):
public void scheduleStatisticsUpdaters(){
  if (!scheduled) {
synchronized (MockHealthStatisticsGenerator.class) {
      if (!scheduled) {
        List<MockHealthStatisticsPattern> statisticsPatterns=MockIaasConfig.getInstance().getMockHealthStatisticsConfig().getStatisticsPatterns();
        for (        MockHealthStatisticsPattern statisticsPattern : statisticsPatterns) {
          scheduledExecutorService.scheduleAtFixedRate(new MockHealthStatisticsUpdater(statisticsPattern),0,statisticsPattern.getSampleDuration(),TimeUnit.SECONDS);
        }
        if (log.isInfoEnabled()) {
          log.info("String_Node_Str");
        }
        scheduled=true;
      }
    }
  }
}
Program: 116098
Project: 116098
Buggy source:
public static void stopStatisticsUpdaters(){
synchronized (MockHealthStatisticsGenerator.class) {
    scheduledExecutorService.shutdownNow();
  }
}

Fixed version (ground truth):
public void stopStatisticsUpdaters(){
synchronized (MockHealthStatisticsGenerator.class) {
    scheduledExecutorService.shutdownNow();
  }
}
Program: 116099
Project: 116099
Buggy source:
@Override public void run(){
  try {
    MockHealthStatistics.getInstance().acquireWriteLock(statisticsPattern.getCartridgeType());
    int nextSample=statisticsPattern.getNextSample();
    MockHealthStatistics.getInstance().addStatistics(statisticsPattern.getCartridgeType(),statisticsPattern.getFactor(),nextSample);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",statisticsPattern.getCartridgeType(),statisticsPattern.getFactor().toString(),nextSample));
    }
  }
  finally {
    MockHealthStatistics.getInstance().releaseWriteLock(statisticsPattern.getCartridgeType());
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    MockHealthStatistics.getInstance().acquireWriteLock(statisticsPattern.getCartridgeType());
    int nextSample=statisticsPattern.getNextSample();
    MockHealthStatistics.getInstance().addStatistics(statisticsPattern.getCartridgeType(),statisticsPattern.getFactor(),nextSample);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",statisticsPattern.getCartridgeType(),statisticsPattern.getFactor().toString(),nextSample));
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
 finally {
    MockHealthStatistics.getInstance().releaseWriteLock(statisticsPattern.getCartridgeType());
  }
}
Program: 116100
Project: 116100
Buggy source:
protected void activate(ComponentContext context){
  try {
    executorService=StratosThreadPool.getExecutorService(DEFAULT_IDENTIFIER,THREAD_POOL_SIZE);
    BundleContext bundleContext=context.getBundleContext();
    bundleContext.registerService(CloudControllerService.class.getName(),new CloudControllerServiceImpl(),null);
    if (CloudControllerContext.getInstance().isClustered()) {
      Thread coordinatorElectorThread=new Thread(){
        @Override public void run(){
          ServiceReferenceHolder.getInstance().getHazelcastInstance().getLock(CLOUD_CONTROLLER_COORDINATOR_LOCK).lock();
          log.info("String_Node_Str" + ServiceReferenceHolder.getInstance().getHazelcastInstance().getCluster().getLocalMember().getUuid() + "String_Node_Str"+ "String_Node_Str");
          CloudControllerContext.getInstance().setCoordinator(true);
          executeCoordinatorTasks();
        }
      }
;
      coordinatorElectorThread.setName("String_Node_Str");
      executorService.submit(coordinatorElectorThread);
    }
 else {
      executeCoordinatorTasks();
    }
    if (MockIaasConfig.getInstance().isEnabled()) {
      MockIaasService.startMockMembersIfPresentInRegistry();
    }
  }
 catch (  Throwable e) {
    log.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
protected void activate(ComponentContext context){
  try {
    executorService=StratosThreadPool.getExecutorService(DEFAULT_IDENTIFIER,THREAD_POOL_SIZE);
    BundleContext bundleContext=context.getBundleContext();
    bundleContext.registerService(CloudControllerService.class.getName(),new CloudControllerServiceImpl(),null);
    if (CloudControllerContext.getInstance().isClustered()) {
      Thread coordinatorElectorThread=new Thread(){
        @Override public void run(){
          ServiceReferenceHolder.getInstance().getHazelcastInstance().getLock(CLOUD_CONTROLLER_COORDINATOR_LOCK).lock();
          log.info("String_Node_Str" + ServiceReferenceHolder.getInstance().getHazelcastInstance().getCluster().getLocalMember().getUuid() + "String_Node_Str"+ "String_Node_Str");
          CloudControllerContext.getInstance().setCoordinator(true);
          executeCoordinatorTasks();
        }
      }
;
      coordinatorElectorThread.setName("String_Node_Str");
      executorService.submit(coordinatorElectorThread);
    }
 else {
      executeCoordinatorTasks();
    }
    if (MockIaasConfig.getInstance().isEnabled()) {
      MockIaasService.getInstance().startMockMembers();
    }
  }
 catch (  Throwable e) {
    log.error("String_Node_Str",e);
  }
}
Program: 116101
Project: 116101
Buggy source:
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent){
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + appId + "String_Node_Str"+ this.getClusterId());
    }
    ClusterStatusEventPublisher.sendClusterTerminatingEvent(getAppId(),getServiceId(),getClusterId(),instanceId);
  }
 else   if (statusEvent.getStatus() == GroupStatus.Created || statusEvent.getStatus() == ApplicationStatus.Created) {
    try {
      createClusterInstanceOnScaleUp(instanceId);
    }
 catch (    PolicyValidationException e) {
      log.error("String_Node_Str",e);
    }
catch (    PartitionValidationException e) {
      log.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
@Override public void onParentStatusEvent(MonitorStatusEvent statusEvent){
  String instanceId=statusEvent.getInstanceId();
  if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + appId + "String_Node_Str"+ this.getClusterId());
    }
    ClusterStatusEventPublisher.sendClusterTerminatingEvent(getAppId(),getServiceId(),getClusterId(),instanceId);
  }
}
Program: 116102
Project: 116102
Buggy source:
/** 
 * Find the group monitor by traversing recursively in the hierarchical monitors.
 * @param groupId the unique alias of the Group
 * @return the found GroupMonitor
 */
public Monitor findGroupMonitorWithId(String groupId){
  return findGroupMonitor(groupId,aliasToActiveMonitorsMap.values());
}

Fixed version (ground truth):
/** 
 * Find the group monitor by traversing recursively in the hierarchical monitors.
 * @param groupId the unique alias of the Group
 * @return the found GroupMonitor
 */
public Monitor findGroupMonitorWithId(String groupId){
  return findGroupMonitor(groupId,aliasToActiveMonitorsMap);
}