Program: 116158
Project: 116158
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 && !stop) {
        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);
            }
            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();
            if (log.isDebugEnabled()) {
              log.debug("String_Node_Str" + rifReset + "String_Node_Str"+ memoryConsumptionReset+ "String_Node_Str"+ loadAverageReset);
            }
            if (rifReset || memoryConsumptionReset || loadAverageReset) {
              VMClusterContext vmClusterContext=(VMClusterContext)clusterContext;
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",vmClusterContext.getAutoscalePolicy());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",rifReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",true);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",memoryConsumptionReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",loadAverageReset);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",hasPrimary);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",primaryMemberListInClusterInstance);
              getMinCheckKnowledgeSession().setGlobal("String_Node_Str",paritionAlgo);
              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 && !stop) {
        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);
            }
            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();
            if (log.isDebugEnabled()) {
              log.debug("String_Node_Str" + rifReset + "String_Node_Str"+ memoryConsumptionReset+ "String_Node_Str"+ loadAverageReset);
            }
            if (rifReset || memoryConsumptionReset || loadAverageReset) {
            }
 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();
      }
    }
  }
}