Program: 115526
Project: 115526
Buggy source:
public void handleAverageRequestsInFlightEvent(AverageRequestsInFlightEvent averageRequestsInFlightEvent){
  String networkPartitionId=averageRequestsInFlightEvent.getNetworkPartitionId();
  String clusterId=averageRequestsInFlightEvent.getClusterId();
  String clusterInstanceId=averageRequestsInFlightEvent.getClusterInstanceId();
  float value=averageRequestsInFlightEvent.getValue();
  if (log.isDebugEnabled()) {
    log.debug(String.format("String_Node_Str" + "String_Node_Str",clusterId,clusterInstanceId,networkPartitionId,value));
  }
  if (clusterInstanceId.equals(StratosConstants.NOT_DEFINED)) {
    NetworkPartitionContext networkPartitionContext=getNetworkPartitionContext(networkPartitionId);
    if (null != networkPartitionContext) {
      int totalActiveMemberCount=0;
      for (      InstanceContext clusterInstanceContext : networkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
        if (clusterInstanceContext instanceof ClusterInstanceContext) {
          totalActiveMemberCount+=((ClusterInstanceContext)clusterInstanceContext).getActiveMemberCount();
        }
      }
      for (      InstanceContext instanceContext : networkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
        if (instanceContext instanceof ClusterInstanceContext) {
          ClusterInstanceContext clusterInstanceContext=((ClusterInstanceContext)instanceContext);
          float averageRequestsInFlight=value * clusterInstanceContext.getActiveMemberCount() / totalActiveMemberCount;
          clusterInstanceContext.setAverageRequestsInFlight(averageRequestsInFlight);
          log.debug(String.format("String_Node_Str" + "String_Node_Str",clusterId,clusterInstanceContext.getId(),networkPartitionId,averageRequestsInFlight));
        }
      }
    }
 else {
      if (log.isDebugEnabled()) {
        log.debug(String.format("String_Node_Str" + "String_Node_Str",networkPartitionId));
      }
    }
  }
 else {
    ClusterInstanceContext clusterInstanceContext=getClusterInstanceContext(networkPartitionId,clusterInstanceId);
    if (null != clusterInstanceContext) {
      clusterInstanceContext.setAverageRequestsInFlight(value);
    }
 else {
      if (log.isDebugEnabled()) {
        log.debug(String.format("String_Node_Str" + "String_Node_Str",clusterInstanceId));
      }
    }
  }
}

Fixed version (ground truth):
public void handleAverageRequestsInFlightEvent(AverageRequestsInFlightEvent averageRequestsInFlightEvent){
  String networkPartitionId=averageRequestsInFlightEvent.getNetworkPartitionId();
  String clusterId=averageRequestsInFlightEvent.getClusterId();
  String clusterInstanceId=averageRequestsInFlightEvent.getClusterInstanceId();
  float value=averageRequestsInFlightEvent.getValue();
  if (log.isDebugEnabled()) {
    log.debug(String.format("String_Node_Str" + "String_Node_Str",clusterId,clusterInstanceId,networkPartitionId,value));
  }
  if (clusterInstanceId.equals(StratosConstants.NOT_DEFINED)) {
    NetworkPartitionContext networkPartitionContext=getNetworkPartitionContext(networkPartitionId);
    if (null != networkPartitionContext) {
      int totalActiveMemberCount=0;
      for (      InstanceContext clusterInstanceContext : networkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
        if (clusterInstanceContext instanceof ClusterInstanceContext) {
          totalActiveMemberCount+=((ClusterInstanceContext)clusterInstanceContext).getActiveMemberCount();
        }
      }
      for (      InstanceContext instanceContext : networkPartitionContext.getInstanceIdToInstanceContextMap().values()) {
        if (instanceContext instanceof ClusterInstanceContext) {
          ClusterInstanceContext clusterInstanceContext=((ClusterInstanceContext)instanceContext);
          float averageRequestsInFlight=value * clusterInstanceContext.getActiveMemberCount() / totalActiveMemberCount;
          clusterInstanceContext.setAverageRequestsInFlight(averageRequestsInFlight);
          if (log.isDebugEnabled()) {
            log.debug(String.format("String_Node_Str" + "String_Node_Str",clusterId,clusterInstanceContext.getId(),networkPartitionId,averageRequestsInFlight));
          }
        }
      }
    }
 else {
      if (log.isDebugEnabled()) {
        log.debug(String.format("String_Node_Str" + "String_Node_Str",networkPartitionId));
      }
    }
  }
 else {
    ClusterInstanceContext clusterInstanceContext=getClusterInstanceContext(networkPartitionId,clusterInstanceId);
    if (null != clusterInstanceContext) {
      clusterInstanceContext.setAverageRequestsInFlight(value);
    }
 else {
      if (log.isDebugEnabled()) {
        log.debug(String.format("String_Node_Str" + "String_Node_Str",clusterInstanceId));
      }
    }
  }
}