Program: 13049
Project: 13049
Buggy source:
public NetworkDiscoveryResult discoverNetwork(Set<ConnectionDetails> connectionDetailsList,int depth){
  nodes.clear();
  Set<ConnectionDetails> discoveredConnectionDetails=new HashSet<ConnectionDetails>();
  Map<String,List<Future<NodeDiscoveryResult>>> nodeNeighbourFuturesMap=new HashMap<String,List<Future<NodeDiscoveryResult>>>();
  Map<String,NodeDiscoveryResult> nodeDiscoveryResultMap=new HashMap<String,NodeDiscoveryResult>();
  int futureCounter=0;
  eventFutureCount=0;
  for (  ConnectionDetails connectionDetails : connectionDetailsList) {
    discoveredConnectionDetails.add(connectionDetails);
    executorCompletionService.submit(discoveryWorkerFactory.createDiscoveryWorker(nodeDiscoverers,connectionDetails,null));
    futureCounter++;
  }
  while (futureCounter > 0) {
    try {
      Future<NodeDiscoveryResult> future=executorCompletionService.take();
      futureCounter--;
      NodeDiscoveryResult result=future.get();
      String nodeId=result.getNodeId();
      String parentId=result.getParentId();
      if (nodeId == null) {
        logger.info("String_Node_Str" + parentId);
        continue;
      }
      if (nodes.containsKey(nodeId)) {
        logger.info("String_Node_Str" + nodeId);
        continue;
      }
      Node node=nodeFactory.createNode(nodeId);
      nodes.put(nodeId,node);
      Node parentNode=nodes.get(parentId);
      if (parentId != null) {
        parentNode.addNeighbour(node);
        List<Future<NodeDiscoveryResult>> parentNeighbourFutures=nodeNeighbourFuturesMap.get(parentId);
        if (parentNeighbourFutures == null) {
          logger.error("String_Node_Str" + parentId);
        }
        parentNeighbourFutures.remove(future);
        if (parentNeighbourFutures.isEmpty()) {
          NodeDiscoveryResult parentDiscoveryResult=nodeDiscoveryResultMap.remove(parentId);
          nodeNeighbourFuturesMap.remove(parentId);
          fireNeighboursDiscoveredEvent(parentDiscoveryResult);
        }
      }
      nodeDiscoveryResultMap.put(nodeId,result);
      fireNodeDiscoveredEvent((NodeDiscoveryResult)result.clone());
      Set<ConnectionDetails> neighboursConnectionDetailsSet=new HashSet<ConnectionDetails>(result.getNeighboursConnectionDetails());
      neighboursConnectionDetailsSet.removeAll(discoveredConnectionDetails);
      ArrayList<Future<NodeDiscoveryResult>> neighbourFutures=new ArrayList<Future<NodeDiscoveryResult>>();
      logger.info("String_Node_Str" + nodeId);
      nodeNeighbourFuturesMap.put(nodeId,neighbourFutures);
      for (      ConnectionDetails neighboursConnectionDetails : neighboursConnectionDetailsSet) {
        discoveredConnectionDetails.add(neighboursConnectionDetails);
        DiscoveryWorker discoveryWorker=new DiscoveryWorker(nodeDiscoverers,neighboursConnectionDetails,nodeId);
        Future<NodeDiscoveryResult> nodeNeighbourFuture=executorCompletionService.submit(discoveryWorker);
        neighbourFutures.add(nodeNeighbourFuture);
        futureCounter++;
      }
    }
 catch (    Exception e) {
      logger.error(e.getMessage(),e);
    }
  }
  NetworkDiscoveryResult result=new NetworkDiscoveryResult();
  result.setNodes(nodes);
  fireNetworkDiscoveredEvent(result);
  while (eventFutureCount > 0) {
    try {
      eventFutureCount--;
      eventExecutorCompletionService.take();
    }
 catch (    InterruptedException e) {
      logger.error(e.getMessage(),e);
    }
  }
  logger.info("String_Node_Str");
  eventExecutorService.shutdown();
  logger.info("String_Node_Str");
  executorService.shutdown();
  return result;
}

Fixed version (ground truth):
public NetworkDiscoveryResult discoverNetwork(Set<ConnectionDetails> connectionDetailsList,int depth){
  nodes.clear();
  Set<ConnectionDetails> discoveredConnectionDetails=new HashSet<ConnectionDetails>();
  Map<String,List<Future<NodeDiscoveryResult>>> nodeNeighbourFuturesMap=new HashMap<String,List<Future<NodeDiscoveryResult>>>();
  Map<String,NodeDiscoveryResult> nodeDiscoveryResultMap=new HashMap<String,NodeDiscoveryResult>();
  int futureCounter=0;
  eventFutureCount=0;
  for (  ConnectionDetails connectionDetails : connectionDetailsList) {
    discoveredConnectionDetails.add(connectionDetails);
    executorCompletionService.submit(discoveryWorkerFactory.createDiscoveryWorker(nodeDiscoverers,connectionDetails,null));
    futureCounter++;
  }
  while (futureCounter > 0) {
    try {
      Future<NodeDiscoveryResult> future=executorCompletionService.take();
      futureCounter--;
      NodeDiscoveryResult result=future.get();
      String parentId=result.getParentId();
      if (parentId != null) {
        List<Future<NodeDiscoveryResult>> parentNeighbourFutures=nodeNeighbourFuturesMap.get(parentId);
        logger.info("String_Node_Str" + parentId + "String_Node_Str"+ future.get().getNodeId());
        parentNeighbourFutures.remove(future);
        if (parentNeighbourFutures.isEmpty()) {
          NodeDiscoveryResult parentDiscoveryResult=nodeDiscoveryResultMap.remove(parentId);
          nodeNeighbourFuturesMap.remove(parentId);
          fireNeighboursDiscoveredEvent(parentDiscoveryResult);
        }
      }
      String nodeId=result.getNodeId();
      if (nodeId == null) {
        logger.info("String_Node_Str" + parentId);
        continue;
      }
      if (nodes.containsKey(nodeId)) {
        logger.info("String_Node_Str" + nodeId);
        continue;
      }
      Node node=nodeFactory.createNode(nodeId);
      nodes.put(nodeId,node);
      Node parentNode=nodes.get(parentId);
      if (parentNode != null) {
        parentNode.addNeighbour(node);
      }
      nodeDiscoveryResultMap.put(nodeId,result);
      fireNodeDiscoveredEvent((NodeDiscoveryResult)result.clone());
      Set<ConnectionDetails> neighboursConnectionDetailsSet=new HashSet<ConnectionDetails>(result.getNeighboursConnectionDetails());
      neighboursConnectionDetailsSet.removeAll(discoveredConnectionDetails);
      ArrayList<Future<NodeDiscoveryResult>> neighbourFutures=new ArrayList<Future<NodeDiscoveryResult>>();
      for (      ConnectionDetails neighboursConnectionDetails : neighboursConnectionDetailsSet) {
        discoveredConnectionDetails.add(neighboursConnectionDetails);
        DiscoveryWorker discoveryWorker=new DiscoveryWorker(nodeDiscoverers,neighboursConnectionDetails,nodeId);
        Future<NodeDiscoveryResult> nodeNeighbourFuture=executorCompletionService.submit(discoveryWorker);
        neighbourFutures.add(nodeNeighbourFuture);
        futureCounter++;
      }
      logger.info("String_Node_Str" + nodeId + "String_Node_Str"+ neighbourFutures.size());
      nodeNeighbourFuturesMap.put(nodeId,neighbourFutures);
    }
 catch (    Exception e) {
      logger.error(e.getMessage(),e);
    }
  }
  NetworkDiscoveryResult result=new NetworkDiscoveryResult();
  result.setNodes(nodes);
  fireNetworkDiscoveredEvent(result);
  while (eventFutureCount > 0) {
    try {
      eventFutureCount--;
      eventExecutorCompletionService.take();
    }
 catch (    InterruptedException e) {
      logger.error(e.getMessage(),e);
    }
  }
  logger.info("String_Node_Str");
  eventExecutorService.shutdown();
  logger.info("String_Node_Str");
  executorService.shutdown();
  return result;
}