Program: 116054
Project: 116054
Buggy source:
public synchronized void monitor(){
  final Collection<NetworkPartitionContext> networkPartitionContexts=this.networkPartitionCtxts.values();
  Runnable monitoringRunnable=new Runnable(){
    @Override public void run(){
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + this.toString());
      }
      for (      NetworkPartitionContext networkPartitionContext : networkPartitionContexts) {
        for (        InstanceContext instanceContext : networkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
          GroupInstance instance=(GroupInstance)instanceIdToInstanceMap.get(instanceContext.getId());
          if (instance.getStatus().getCode() <= GroupStatus.Active.getCode()) {
            if (!instanceContext.getIdToScalingOverMaxEvent().isEmpty()) {
              if (groupScalingEnabled) {
                boolean createOnDemand=createInstanceOnDemand(instanceContext.getParentInstanceId());
                if (!createOnDemand) {
                  MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),instanceContext.getId(),appId);
                }
 else {
                  instanceContext.setIdToScalingOverMaxEvent(new HashMap<String,ScalingOverMaxEvent>());
                }
              }
 else {
                MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),instanceContext.getId(),appId);
              }
            }
 else {
              handleDependentScaling(instanceContext,networkPartitionContext);
            }
          }
        }
      }
    }
  }
;
  monitoringRunnable.run();
}

Fixed version (ground truth):
public synchronized void monitor(){
  final Collection<NetworkPartitionContext> networkPartitionContexts=this.networkPartitionCtxts.values();
  Runnable monitoringRunnable=new Runnable(){
    @Override public void run(){
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + this.toString());
      }
      for (      NetworkPartitionContext networkPartitionContext : networkPartitionContexts) {
        for (        InstanceContext instanceContext : networkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
          GroupInstance instance=(GroupInstance)instanceIdToInstanceMap.get(instanceContext.getId());
          if (instance.getStatus().getCode() <= GroupStatus.Active.getCode()) {
            if (!instanceContext.getIdToScalingOverMaxEvent().isEmpty()) {
              if (groupScalingEnabled) {
                if (log.isDebugEnabled()) {
                  log.debug("String_Node_Str" + id + "String_Node_Str"+ "String_Node_Str");
                }
                boolean createOnDemand=createInstanceOnDemand(instanceContext.getParentInstanceId());
                if (!createOnDemand) {
                  MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),instanceContext.getId(),appId);
                }
 else {
                  instanceContext.setIdToScalingOverMaxEvent(new HashMap<String,ScalingOverMaxEvent>());
                }
              }
 else {
                MonitorStatusEventBuilder.handleScalingOverMaxEvent(parent,networkPartitionContext.getId(),instanceContext.getId(),appId);
              }
            }
 else {
              handleDependentScaling(instanceContext,networkPartitionContext);
            }
          }
        }
      }
    }
  }
;
  monitoringRunnable.run();
}