Program: 116026
Project: 116026
Buggy source:
private void handleScalingDownBeyondMin(InstanceContext instanceContext,NetworkPartitionContext nwPartitionContext){
  boolean allChildrenScaleDown=false;
  for (  Monitor monitor : this.aliasToActiveMonitorsMap.values()) {
    if (instanceContext.getScalingDownBeyondMinEvent(monitor.getId()) == null) {
      allChildrenScaleDown=false;
      break;
    }
 else {
      allChildrenScaleDown=true;
    }
  }
  if (allChildrenScaleDown) {
    if (hasScalingDependents) {
      if (nwPartitionContext.getNonTerminatedInstancesCount() > ((GroupLevelNetworkPartitionContext)nwPartitionContext).getMinInstanceCount()) {
        float minInstances=((GroupLevelNetworkPartitionContext)nwPartitionContext).getMinInstanceCount();
        float factor=(nwPartitionContext.getNonTerminatedInstancesCount() - 1) / minInstances;
        ScalingEvent scalingEvent=new ScalingEvent(this.id,nwPartitionContext.getId(),instanceContext.getId(),factor);
        this.parent.onChildScalingEvent(scalingEvent);
      }
 else {
        ScalingDownBeyondMinEvent newScalingDownBeyondMinEvent=new ScalingDownBeyondMinEvent(this.id,nwPartitionContext.getId(),instanceContext.getParentInstanceId());
        this.parent.onChildScalingDownBeyondMinEvent(newScalingDownBeyondMinEvent);
      }
    }
 else {
      if (groupScalingEnabled) {
        if (nwPartitionContext.getNonTerminatedInstancesCount() > ((GroupLevelNetworkPartitionContext)nwPartitionContext).getMinInstanceCount()) {
          ApplicationBuilder.handleGroupTerminatingEvent(this.appId,this.id,instanceContext.getId());
        }
      }
 else {
        ScalingDownBeyondMinEvent newScalingDownBeyondMinEvent=new ScalingDownBeyondMinEvent(this.id,nwPartitionContext.getId(),instanceContext.getParentInstanceId());
        this.parent.onChildScalingDownBeyondMinEvent(newScalingDownBeyondMinEvent);
      }
    }
  }
  instanceContext.setIdToScalingDownBeyondMinEvent(new HashMap<String,ScalingDownBeyondMinEvent>());
}

Fixed version (ground truth):
private void handleScalingDownBeyondMin(InstanceContext instanceContext,NetworkPartitionContext nwPartitionContext){
  boolean allChildrenScaleDown=false;
  for (  Monitor monitor : this.aliasToActiveMonitorsMap.values()) {
    if (instanceContext.getScalingDownBeyondMinEvent(monitor.getId()) == null) {
      allChildrenScaleDown=false;
      break;
    }
 else {
      allChildrenScaleDown=true;
    }
  }
  if (allChildrenScaleDown) {
    if (hasScalingDependents) {
      if (nwPartitionContext.getNonTerminatedInstancesCount() > ((GroupLevelNetworkPartitionContext)nwPartitionContext).getMinInstanceCount()) {
        float minInstances=((GroupLevelNetworkPartitionContext)nwPartitionContext).getMinInstanceCount();
        float factor=(nwPartitionContext.getNonTerminatedInstancesCount() - 1) / minInstances;
        ScalingEvent scalingEvent=new ScalingEvent(this.id,nwPartitionContext.getId(),instanceContext.getId(),factor);
        this.parent.onChildScalingEvent(scalingEvent);
      }
 else {
        ScalingDownBeyondMinEvent newScalingDownBeyondMinEvent=new ScalingDownBeyondMinEvent(this.id,nwPartitionContext.getId(),instanceContext.getParentInstanceId());
        this.parent.onChildScalingDownBeyondMinEvent(newScalingDownBeyondMinEvent);
      }
    }
 else {
      if (groupScalingEnabled) {
        if (nwPartitionContext.getNonTerminatedInstancesCount() > ((GroupLevelNetworkPartitionContext)nwPartitionContext).getMinInstanceCount()) {
          ApplicationBuilder.handleGroupTerminatingEvent(this.appId,this.id,instanceContext.getId());
        }
      }
 else {
        ScalingDownBeyondMinEvent newScalingDownBeyondMinEvent=new ScalingDownBeyondMinEvent(this.id,nwPartitionContext.getId(),instanceContext.getParentInstanceId());
        this.parent.onChildScalingDownBeyondMinEvent(newScalingDownBeyondMinEvent);
      }
    }
  }
  instanceContext.setIdToScalingDownBeyondMinEvent(new ConcurrentHashMap<String,ScalingDownBeyondMinEvent>());
}