Program: 116090
Project: 116090
Buggy source:
public void monitor(){
  for (  ClusterLevelNetworkPartitionContext networkPartitionContext : getNetworkPartitionCtxts()) {
    final Collection<ClusterInstanceContext> clusterInstanceContexts=networkPartitionContext.getClusterInstanceContextMap().values();
    for (    final ClusterInstanceContext instanceContext : clusterInstanceContexts) {
      ClusterInstance instance=(ClusterInstance)this.instanceIdToInstanceMap.get(instanceContext.getId());
      if ((instance.getStatus().getCode() <= ClusterStatus.Active.getCode()) || (instance.getStatus() == ClusterStatus.Inactive && !hasStartupDependents) && !this.hasFaultyMember) {
        Runnable monitoringRunnable=new Runnable(){
          @Override public void run(){
            if (log.isDebugEnabled()) {
              log.debug("String_Node_Str" + getClusterId());
            }
            List<String> primaryMemberListInClusterInstance=new ArrayList<String>();
            for (            ClusterLevelPartitionContext partitionContext : instanceContext.getPartitionCtxts()) {
              for (              MemberContext memberContext : partitionContext.getActiveMembers()) {
                if (isPrimaryMember(memberContext)) {
                  primaryMemberListInClusterInstance.add(memberContext.getMemberId());
                }
              }
              for (              MemberContext memberContext : partitionContext.getPendingMembers()) {
                if (isPrimaryMember(memberContext)) {
                  primaryMemberListInClusterInstance.add(memberContext.getMemberId());
                }
              }
              obsoleteCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getObsoleteCheckKnowledgeSession(),obsoleteCheckFactHandle,partitionContext);
            }
            getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",primaryMemberListInClusterInstance);
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",hasPrimary);
            String paritionAlgo=instanceContext.getPartitionAlgorithm();
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",paritionAlgo);
            if (log.isDebugEnabled()) {
              log.debug(String.format("String_Node_Str",instanceContext.getId()));
            }
            minCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getMinCheckKnowledgeSession(),minCheckFactHandle,instanceContext);
            boolean rifReset=instanceContext.isRifReset();
            boolean memoryConsumptionReset=instanceContext.isMemoryConsumptionReset();
            boolean loadAverageReset=instanceContext.isLoadAverageReset();
            boolean averageRequestServedPerInstanceReset=instanceContext.isAverageRequestServedPerInstanceReset();
            if (log.isDebugEnabled()) {
              log.debug("String_Node_Str" + rifReset + "String_Node_Str"+ memoryConsumptionReset+ "String_Node_Str"+ loadAverageReset);
            }
            if (rifReset || memoryConsumptionReset || loadAverageReset) {
              log.info("String_Node_Str");
              VMClusterContext vmClusterContext=(VMClusterContext)clusterContext;
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",rifReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",memoryConsumptionReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",loadAverageReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",hasPrimary);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",paritionAlgo);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",vmClusterContext.getAutoscalePolicy());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",averageRequestServedPerInstanceReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",primaryMemberListInClusterInstance);
              if (log.isDebugEnabled()) {
                log.debug(String.format("String_Node_Str",instanceContext.getId()));
                log.debug("String_Node_Str" + primaryMemberListInClusterInstance);
              }
              scaleCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getScaleCheckKnowledgeSession(),scaleCheckFactHandle,instanceContext);
              instanceContext.setRifReset(false);
              instanceContext.setMemoryConsumptionReset(false);
              instanceContext.setLoadAverageReset(false);
            }
 else             if (log.isDebugEnabled()) {
              log.debug(String.format("String_Node_Str" + "String_Node_Str",instanceContext.getId()));
            }
          }
        }
;
        monitoringRunnable.run();
      }
      for (      final ClusterLevelPartitionContext partitionContext : instanceContext.getPartitionCtxts()) {
        Runnable monitoringRunnable=new Runnable(){
          @Override public void run(){
            obsoleteCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getObsoleteCheckKnowledgeSession(),obsoleteCheckFactHandle,partitionContext);
          }
        }
;
        monitoringRunnable.run();
      }
    }
  }
}

Fixed version (ground truth):
public void monitor(){
  for (  ClusterLevelNetworkPartitionContext networkPartitionContext : getNetworkPartitionCtxts()) {
    final Collection<ClusterInstanceContext> clusterInstanceContexts=networkPartitionContext.getClusterInstanceContextMap().values();
    for (    final ClusterInstanceContext instanceContext : clusterInstanceContexts) {
      ClusterInstance instance=(ClusterInstance)this.instanceIdToInstanceMap.get(instanceContext.getId());
      if ((instance.getStatus().getCode() <= ClusterStatus.Active.getCode()) || (instance.getStatus() == ClusterStatus.Inactive && !hasStartupDependents) && !this.hasFaultyMember) {
        Runnable monitoringRunnable=new Runnable(){
          @Override public void run(){
            if (log.isDebugEnabled()) {
              log.debug("String_Node_Str" + getClusterId());
            }
            List<String> primaryMemberListInClusterInstance=new ArrayList<String>();
            for (            ClusterLevelPartitionContext partitionContext : instanceContext.getPartitionCtxts()) {
              for (              MemberContext memberContext : partitionContext.getActiveMembers()) {
                if (isPrimaryMember(memberContext)) {
                  primaryMemberListInClusterInstance.add(memberContext.getMemberId());
                }
              }
              for (              MemberContext memberContext : partitionContext.getPendingMembers()) {
                if (isPrimaryMember(memberContext)) {
                  primaryMemberListInClusterInstance.add(memberContext.getMemberId());
                }
              }
              obsoleteCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getObsoleteCheckKnowledgeSession(),obsoleteCheckFactHandle,partitionContext);
            }
            getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",primaryMemberListInClusterInstance);
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",hasPrimary);
            String paritionAlgo=instanceContext.getPartitionAlgorithm();
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",paritionAlgo);
            if (log.isDebugEnabled()) {
              log.debug(String.format("String_Node_Str",instanceContext.getId() + "String_Node_Str" + clusterId));
            }
            minCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getMinCheckKnowledgeSession(),minCheckFactHandle,instanceContext);
            boolean rifReset=instanceContext.isRifReset();
            boolean memoryConsumptionReset=instanceContext.isMemoryConsumptionReset();
            boolean loadAverageReset=instanceContext.isLoadAverageReset();
            boolean averageRequestServedPerInstanceReset=instanceContext.isAverageRequestServedPerInstanceReset();
            if (log.isDebugEnabled()) {
              log.debug("String_Node_Str" + rifReset + "String_Node_Str"+ memoryConsumptionReset+ "String_Node_Str"+ loadAverageReset);
            }
            if (rifReset || memoryConsumptionReset || loadAverageReset) {
              log.info("String_Node_Str");
              VMClusterContext vmClusterContext=(VMClusterContext)clusterContext;
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",rifReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",memoryConsumptionReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",loadAverageReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",hasPrimary);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",paritionAlgo);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",vmClusterContext.getAutoscalePolicy());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",averageRequestServedPerInstanceReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",primaryMemberListInClusterInstance);
              if (log.isDebugEnabled()) {
                log.debug(String.format("String_Node_Str",instanceContext.getId()));
                log.debug("String_Node_Str" + primaryMemberListInClusterInstance);
              }
              scaleCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getScaleCheckKnowledgeSession(),scaleCheckFactHandle,instanceContext);
              instanceContext.setRifReset(false);
              instanceContext.setMemoryConsumptionReset(false);
              instanceContext.setLoadAverageReset(false);
            }
 else             if (log.isDebugEnabled()) {
              log.debug(String.format("String_Node_Str" + "String_Node_Str",instanceContext.getId()));
            }
          }
        }
;
        monitoringRunnable.run();
      }
      for (      final ClusterLevelPartitionContext partitionContext : instanceContext.getPartitionCtxts()) {
        Runnable monitoringRunnable=new Runnable(){
          @Override public void run(){
            obsoleteCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getObsoleteCheckKnowledgeSession(),obsoleteCheckFactHandle,partitionContext);
          }
        }
;
        monitoringRunnable.run();
      }
    }
  }
}