Program: 18093
Project: 18093
Buggy source:
/** 
 * Establishes connection to host specified by this object. If this is active connection then it will try to connect to other side. Otherwise we will wait until connection will be set-up using <code>setConnection</code> method. This method will return only if the connection is established and initialized properly.
 * @throws InterruptedException
 */
private void connect() throws InterruptedException {
  if (active) {
    while (true) {
      try {
        socket=new Socket();
        socket.setReceiveBufferSize(128 * 1024);
        socket.setSendBufferSize(128 * 1024);
        logger.fine("String_Node_Str" + socket.getReceiveBufferSize() + "String_Node_Str"+ socket.getSendBufferSize());
        socket.setTcpNoDelay(true);
        logger.info("String_Node_Str" + replica);
        try {
          socket.connect(new InetSocketAddress(replica.getHostname(),replica.getReplicaPort()));
        }
 catch (        ConnectException e) {
          logger.warning("String_Node_Str" + replica.getId() + "String_Node_Str");
          Thread.sleep(ProcessDescriptor.getInstance().tcpReconnectTimeout);
          continue;
        }
        input=new DataInputStream(new BufferedInputStream(socket.getInputStream()));
        output=new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
        output.writeInt(ProcessDescriptor.getInstance().localId);
        output.flush();
        break;
      }
 catch (      IOException e) {
        logger.log(Level.WARNING,"String_Node_Str" + replica,e);
      }
      Thread.sleep(ProcessDescriptor.getInstance().tcpReconnectTimeout);
    }
synchronized (this) {
      connected=true;
      notifyAll();
    }
  }
 else {
synchronized (this) {
      while (!connected) {
        wait();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Establishes connection to host specified by this object. If this is active connection then it will try to connect to other side. Otherwise we will wait until connection will be set-up using <code>setConnection</code> method. This method will return only if the connection is established and initialized properly.
 * @throws InterruptedException
 */
private void connect() throws InterruptedException {
  if (active) {
    while (true) {
      try {
        socket=new Socket();
        socket.setReceiveBufferSize(128 * 1024);
        socket.setSendBufferSize(128 * 1024);
        logger.fine("String_Node_Str" + socket.getReceiveBufferSize() + "String_Node_Str"+ socket.getSendBufferSize());
        socket.setTcpNoDelay(true);
        logger.info("String_Node_Str" + replica);
        try {
          socket.connect(new InetSocketAddress(replica.getHostname(),replica.getReplicaPort()));
        }
 catch (        ConnectException e) {
          logger.warning("String_Node_Str" + replica.getId() + "String_Node_Str");
          Thread.sleep(ProcessDescriptor.getInstance().tcpReconnectTimeout);
          continue;
        }
        input=new DataInputStream(new BufferedInputStream(socket.getInputStream()));
        output=new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
        output.writeInt(ProcessDescriptor.getInstance().localId);
        output.flush();
        break;
      }
 catch (      IOException e) {
        long sleepTime=ProcessDescriptor.getInstance().tcpReconnectTimeout;
        logger.log(Level.WARNING,"String_Node_Str" + replica + "String_Node_Str"+ sleepTime,e);
        Thread.sleep(sleepTime);
      }
    }
synchronized (this) {
      connected=true;
      notifyAll();
    }
  }
 else {
synchronized (this) {
      while (!connected) {
        wait();
      }
    }
  }
}