Program: 116189
Project: 116189
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()) || (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());
                }
              }
            }
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",hasPrimary);
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",instanceContext.getPartitionAlgorithm());
            if (log.isDebugEnabled()) {
              log.debug(String.format("String_Node_Str",instanceContext.getId()));
            }
            minCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getMinCheckKnowledgeSession(),minCheckFactHandle,instanceContext);
            obsoleteCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getObsoleteCheckKnowledgeSession(),obsoleteCheckFactHandle,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",instanceContext);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",vmClusterContext.getAutoscalePolicy());
              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",primaryMemberListInClusterInstance);
              getMinCheckKnowledgeSession().setGlobal("String_Node_Str",instanceContext.getPartitionAlgorithm());
              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();
      }
    }
  }
}

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()) || (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());
                }
              }
            }
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",hasPrimary);
            String paritionAlgo=instanceContext.getPartitionAlgorithm();
            if (paritionAlgo == null) {
              paritionAlgo="String_Node_Str";
            }
            getMinCheckKnowledgeSession().setGlobal("String_Node_Str",paritionAlgo);
            if (log.isDebugEnabled()) {
              log.debug(String.format("String_Node_Str",instanceContext.getId()));
            }
            minCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getMinCheckKnowledgeSession(),minCheckFactHandle,instanceContext);
            obsoleteCheckFactHandle=AutoscalerRuleEvaluator.evaluate(getObsoleteCheckKnowledgeSession(),obsoleteCheckFactHandle,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",instanceContext);
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",getClusterId());
              getScaleCheckKnowledgeSession().setGlobal("String_Node_Str",vmClusterContext.getAutoscalePolicy());
              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",primaryMemberListInClusterInstance);
              getMinCheckKnowledgeSession().setGlobal("String_Node_Str",instanceContext.getPartitionAlgorithm());
              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();
      }
    }
  }
}