Program: 50303
Project: 50303
Buggy source:
private void joinViaPossibleMembers(){
  try {
    failedConnections.clear();
    final Collection<Address> colPossibleAddresses=getPossibleMembers();
    colPossibleAddresses.remove(address);
    for (    final Address possibleAddress : colPossibleAddresses) {
      logger.log(Level.FINEST,"String_Node_Str" + possibleAddress);
      connectionManager.getOrConnect(possibleAddress);
    }
    boolean found=false;
    int numberOfSeconds=0;
    final int connectionTimeoutSeconds=config.getNetworkConfig().getJoin().getTcpIpConfig().getConnectionTimeoutSeconds();
    while (!found && numberOfSeconds < connectionTimeoutSeconds) {
      colPossibleAddresses.removeAll(failedConnections);
      if (colPossibleAddresses.size() == 0) {
        break;
      }
      Thread.sleep(1000L);
      numberOfSeconds++;
      int numberOfJoinReq=0;
      logger.log(Level.FINE,"String_Node_Str");
      for (      Address possibleAddress : colPossibleAddresses) {
        logger.log(Level.FINEST,"String_Node_Str" + numberOfJoinReq + "String_Node_Str"+ possibleAddress);
        final Connection conn=connectionManager.getOrConnect(possibleAddress);
        if (conn != null && numberOfJoinReq < 5) {
          found=true;
          logger.log(Level.FINEST,"String_Node_Str" + possibleAddress);
          clusterManager.sendJoinRequest(possibleAddress);
          numberOfJoinReq++;
        }
 else {
          logger.log(Level.FINEST,"String_Node_Str" + possibleAddress);
        }
      }
    }
    logger.log(Level.FINEST,"String_Node_Str" + found);
    if (!found) {
      logger.log(Level.FINEST,"String_Node_Str");
      setAsMaster();
    }
 else {
      while (!joined) {
        int numberOfJoinReq=0;
        colPossibleAddresses.removeAll(failedConnections);
        for (        Address possibleAddress : colPossibleAddresses) {
          final Connection conn=connectionManager.getOrConnect(possibleAddress);
          if (conn != null && numberOfJoinReq < 5) {
            logger.log(Level.FINEST,"String_Node_Str" + possibleAddress);
            clusterManager.sendJoinRequest(possibleAddress);
            numberOfJoinReq++;
          }
 else {
            logger.log(Level.FINEST,"String_Node_Str" + possibleAddress + "String_Node_Str");
          }
        }
        int maxTryCount=3;
        for (        Address possibleAddress : colPossibleAddresses) {
          if (address.hashCode() > possibleAddress.hashCode()) {
            maxTryCount=6;
            break;
          }
 else           if (address.hashCode() == possibleAddress.hashCode()) {
            maxTryCount=3 + ((int)(Math.random() * 10));
            break;
          }
        }
        int tryCount=0;
        while (tryCount++ < maxTryCount && (masterAddress == null)) {
          Thread.sleep(1000L);
        }
        if (masterAddress == null) {
          boolean masterCandidate=true;
          for (          Address address : colPossibleAddresses) {
            if (this.address.hashCode() > address.hashCode()) {
              masterCandidate=false;
            }
          }
          if (masterCandidate) {
            logger.log(Level.FINEST,"String_Node_Str");
            setAsMaster();
          }
        }
      }
    }
    colPossibleAddresses.clear();
    failedConnections.clear();
  }
 catch (  Exception e) {
    e.printStackTrace();
    logger.log(Level.SEVERE,e.getMessage(),e);
  }
}

Fixed version (ground truth):
private void joinViaPossibleMembers(){
  try {
    failedConnections.clear();
    final Collection<Address> colPossibleAddresses=getPossibleMembers();
    colPossibleAddresses.remove(address);
    for (    final Address possibleAddress : colPossibleAddresses) {
      logger.log(Level.FINEST,"String_Node_Str" + possibleAddress);
      connectionManager.getOrConnect(possibleAddress);
    }
    boolean found=false;
    int numberOfSeconds=0;
    final int connectionTimeoutSeconds=config.getNetworkConfig().getJoin().getTcpIpConfig().getConnectionTimeoutSeconds();
    while (!found && numberOfSeconds < connectionTimeoutSeconds) {
      colPossibleAddresses.removeAll(failedConnections);
      if (colPossibleAddresses.size() == 0) {
        break;
      }
      Thread.sleep(1000L);
      numberOfSeconds++;
      int numberOfJoinReq=0;
      logger.log(Level.FINEST,"String_Node_Str");
      for (      Address possibleAddress : colPossibleAddresses) {
        logger.log(Level.FINEST,"String_Node_Str" + numberOfJoinReq + "String_Node_Str"+ possibleAddress);
        final Connection conn=connectionManager.getOrConnect(possibleAddress);
        if (conn != null && numberOfJoinReq < 5) {
          found=true;
          logger.log(Level.FINEST,"String_Node_Str" + possibleAddress);
          clusterManager.sendJoinRequest(possibleAddress);
          numberOfJoinReq++;
        }
 else {
          logger.log(Level.FINEST,"String_Node_Str" + possibleAddress);
        }
      }
    }
    logger.log(Level.FINEST,"String_Node_Str" + found);
    if (!found) {
      logger.log(Level.FINEST,"String_Node_Str");
      setAsMaster();
    }
 else {
      while (!joined) {
        int maxTryCount=3;
        for (        Address possibleAddress : colPossibleAddresses) {
          if (address.hashCode() > possibleAddress.hashCode()) {
            maxTryCount=6;
            break;
          }
 else           if (address.hashCode() == possibleAddress.hashCode()) {
            maxTryCount=3 + ((int)(Math.random() * 10));
            break;
          }
        }
        int tryCount=0;
        while (tryCount++ < maxTryCount && (masterAddress == null)) {
          connectAndSendJoinRequest(colPossibleAddresses);
          Thread.sleep(1000L);
        }
        while (masterAddress != null && !joined) {
          Thread.sleep(1000L);
          clusterManager.sendJoinRequest(masterAddress);
        }
        if (masterAddress == null) {
          boolean masterCandidate=true;
          for (          Address address : colPossibleAddresses) {
            if (this.address.hashCode() > address.hashCode()) {
              masterCandidate=false;
            }
          }
          if (masterCandidate) {
            logger.log(Level.FINEST,"String_Node_Str");
            setAsMaster();
          }
        }
      }
    }
    colPossibleAddresses.clear();
    failedConnections.clear();
  }
 catch (  Exception e) {
    e.printStackTrace();
    logger.log(Level.SEVERE,e.getMessage(),e);
  }
}