Program: 107127
Project: 107127
Buggy source:
private void peerScan(){
  Date cutTime=DateUtil.currentGMTTime();
  List<ManagementServerHostVO> currentList=_mshostDao.getActiveList(new Date(cutTime.getTime() - heartbeatThreshold));
  List<ManagementServerHostVO> removedNodeList=new ArrayList<ManagementServerHostVO>();
  if (_mshostId != null) {
    for (    Map.Entry<Long,ManagementServerHostVO> entry : activePeers.entrySet()) {
      if (!isIdInList(entry.getKey(),currentList)) {
        if (entry.getKey().longValue() != _mshostId.longValue()) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue().getServiceIP());
          }
          removedNodeList.add(entry.getValue());
        }
      }
    }
  }
  Iterator<ManagementServerHostVO> it=removedNodeList.iterator();
  while (it.hasNext()) {
    ManagementServerHostVO mshost=it.next();
    if (!pingManagementNode(mshost.getId())) {
      s_logger.warn("String_Node_Str" + mshost.getId() + "String_Node_Str");
      activePeers.remove(mshost.getId());
      try {
        JmxUtil.unregisterMBean("String_Node_Str","String_Node_Str" + mshost.getId());
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str" + e.toString());
      }
    }
 else {
      s_logger.info("String_Node_Str" + mshost.getId() + "String_Node_Str");
      it.remove();
    }
  }
  List<ManagementServerHostVO> newNodeList=new ArrayList<ManagementServerHostVO>();
  for (  ManagementServerHostVO mshost : currentList) {
    if (!activePeers.containsKey(mshost.getId())) {
      activePeers.put(mshost.getId(),mshost);
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + mshost.getId() + "String_Node_Str"+ mshost.getServiceIP());
      }
      newNodeList.add(mshost);
      try {
        JmxUtil.registerMBean("String_Node_Str","String_Node_Str" + mshost.getId(),new ClusterManagerMBeanImpl(this,mshost));
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str" + e.toString());
      }
    }
  }
  if (newNodeList.size() > 0) {
    Profiler profiler=new Profiler();
    profiler.start();
    notifyNodeJoined(newNodeList);
    profiler.stop();
    if (profiler.getDuration() > 1000) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
 else {
      s_logger.warn("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
  }
  if (removedNodeList.size() > 0) {
    Profiler profiler=new Profiler();
    profiler.start();
    notifyNodeLeft(removedNodeList);
    profiler.stop();
    if (profiler.getDuration() > 1000) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
 else {
      s_logger.warn("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void peerScan(){
  Date cutTime=DateUtil.currentGMTTime();
  List<ManagementServerHostVO> currentList=_mshostDao.getActiveList(new Date(cutTime.getTime() - heartbeatThreshold));
  List<ManagementServerHostVO> removedNodeList=new ArrayList<ManagementServerHostVO>();
  if (_mshostId != null) {
    for (    Map.Entry<Long,ManagementServerHostVO> entry : activePeers.entrySet()) {
      if (!isIdInList(entry.getKey(),currentList)) {
        if (entry.getKey().longValue() != _mshostId.longValue()) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue().getServiceIP());
          }
          removedNodeList.add(entry.getValue());
        }
      }
    }
  }
  Iterator<ManagementServerHostVO> it=removedNodeList.iterator();
  while (it.hasNext()) {
    ManagementServerHostVO mshost=it.next();
    if (!pingManagementNode(mshost.getMsid())) {
      s_logger.warn("String_Node_Str" + mshost.getId() + "String_Node_Str");
      activePeers.remove(mshost.getId());
      try {
        JmxUtil.unregisterMBean("String_Node_Str","String_Node_Str" + mshost.getId());
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str" + e.toString());
      }
    }
 else {
      s_logger.info("String_Node_Str" + mshost.getId() + "String_Node_Str");
      it.remove();
    }
  }
  List<ManagementServerHostVO> newNodeList=new ArrayList<ManagementServerHostVO>();
  for (  ManagementServerHostVO mshost : currentList) {
    if (!activePeers.containsKey(mshost.getId())) {
      activePeers.put(mshost.getId(),mshost);
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + mshost.getId() + "String_Node_Str"+ mshost.getServiceIP());
      }
      newNodeList.add(mshost);
      try {
        JmxUtil.registerMBean("String_Node_Str","String_Node_Str" + mshost.getId(),new ClusterManagerMBeanImpl(this,mshost));
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str" + e.toString());
      }
    }
  }
  if (newNodeList.size() > 0) {
    Profiler profiler=new Profiler();
    profiler.start();
    notifyNodeJoined(newNodeList);
    profiler.stop();
    if (profiler.getDuration() > 1000) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
 else {
      s_logger.warn("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
  }
  if (removedNodeList.size() > 0) {
    Profiler profiler=new Profiler();
    profiler.start();
    notifyNodeLeft(removedNodeList);
    profiler.stop();
    if (profiler.getDuration() > 1000) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
 else {
      s_logger.warn("String_Node_Str" + profiler.getDuration() + "String_Node_Str");
    }
  }
}