Program: 70361
Project: 70361
Buggy source:
public NIONode startWorker() throws InitNodeException {
  String name=nw.getName();
  String user=nw.getUser();
  int minPort=nw.getConfiguration().getMinPort();
  int maxPort=nw.getConfiguration().getMaxPort();
  int port=minPort;
  NIONode n=null;
  int pid=-1;
  while (port <= maxPort && !toStop) {
    String[] command;
    if (pid != -1) {
      command=getStopCommand(pid);
      ProcessOut po=executeCommand(user,name,command);
      if (po == null) {
        logger.error("String_Node_Str" + name + "String_Node_Str");
        throw new InitNodeException("String_Node_Str" + name + "String_Node_Str");
      }
 else       if (po.getExitValue() != 0) {
        logger.error(ERROR_SHUTTING_DOWN_RETRY);
      }
      pid=-1;
    }
    n=new NIONode(name,port);
    String nodeName=nw.getName();
    addresstoWorkerStarter.put(nodeName,this);
    logger.debug("String_Node_Str");
    command=getStartCommand(nw,port);
    long timer=0;
    while (pid < 0) {
      timer=timer + (WAIT_TIME_UNIT * 4);
      try {
        Thread.sleep(WAIT_TIME_UNIT * 4);
      }
 catch (      Exception e) {
      }
      ProcessOut po=executeCommand(user,name,command);
      if (po == null) {
        logger.debug("String_Node_Str" + name + "String_Node_Str");
        pid=0;
      }
 else       if (po.getExitValue() == 0) {
        String output=po.getOutput();
        String[] lines=output.split("String_Node_Str");
        pid=Integer.parseInt(lines[lines.length - 1]);
      }
 else {
        if (timer > MAX_WAIT_FOR_SSH) {
          throw new InitNodeException("String_Node_Str" + name + "String_Node_Str"+ user+ "String_Node_Str"+ "String_Node_Str"+ po.getOutput()+ "String_Node_Str"+ "String_Node_Str"+ po.getError()+ "String_Node_Str");
        }
        logger.debug("String_Node_Str" + name + "String_Node_Str");
      }
    }
    long delay=WAIT_TIME_UNIT;
    long totalWait=0;
    logger.debug("String_Node_Str");
    CommandCheckWorker cmd=new CommandCheckWorker(DEPLOYMENT_ID,nodeName);
    while ((!workerIsReady) && (totalWait < MAX_WAIT_FOR_INIT) && !toStop) {
      try {
        logger.debug("String_Node_Str" + delay);
        Thread.sleep(delay);
      }
 catch (      InterruptedException ie) {
        Thread.currentThread().interrupt();
      }
      if (!workerIsReady) {
        if (debug) {
          logger.debug("String_Node_Str" + nodeName);
        }
        Connection c=NIOAdaptor.tm.startConnection(n);
        c.sendCommand(cmd);
        c.receive();
        c.finishConnection();
        totalWait+=delay;
        delay=(delay < 3900) ? delay * 2 : 4000;
      }
    }
    logger.debug("String_Node_Str" + nodeName + "String_Node_Str");
    if (!workerIsReady) {
      ++port;
    }
 else {
      try {
        Runtime.getRuntime().addShutdownHook(new Ender(this,nw,pid));
      }
 catch (      IllegalStateException e) {
        logger.warn("String_Node_Str",e);
      }
      return n;
    }
  }
  if (toStop) {
    String msg="String_Node_Str" + name + "String_Node_Str";
    logger.warn(msg);
    throw new InitNodeException(msg);
  }
 else   if (!workerIsReady) {
    String msg="String_Node_Str" + name + "String_Node_Str"+ user+ "String_Node_Str";
    logger.warn(msg);
    throw new InitNodeException(msg);
  }
 else {
    String msg="String_Node_Str" + name + "String_Node_Str"+ user+ "String_Node_Str";
    logger.warn(msg);
    throw new InitNodeException(msg);
  }
}

Fixed version (ground truth):
public NIONode startWorker() throws InitNodeException {
  String name=nw.getName();
  String user=nw.getUser();
  int minPort=nw.getConfiguration().getMinPort();
  int maxPort=nw.getConfiguration().getMaxPort();
  int port=minPort;
synchronized (addresstoWorkerStarter) {
    addresstoWorkerStarter.put(name,this);
    logger.debug("String_Node_Str" + name + "String_Node_Str");
  }
  NIONode n=null;
  int pid=-1;
  while (port <= maxPort && !toStop) {
    String[] command;
    if (pid != -1) {
      command=getStopCommand(pid);
      ProcessOut po=executeCommand(user,name,command);
      if (po == null) {
        logger.error("String_Node_Str" + name + "String_Node_Str");
        throw new InitNodeException("String_Node_Str" + name + "String_Node_Str");
      }
 else       if (po.getExitValue() != 0) {
        logger.error(ERROR_SHUTTING_DOWN_RETRY);
      }
      pid=-1;
    }
    n=new NIONode(name,port);
    command=getStartCommand(nw,port);
    long timer=0;
    while (pid < 0) {
      timer=timer + (WAIT_TIME_UNIT * 4);
      try {
        Thread.sleep(WAIT_TIME_UNIT * 4);
      }
 catch (      Exception e) {
      }
      ProcessOut po=executeCommand(user,name,command);
      if (po == null) {
        logger.debug("String_Node_Str" + name + "String_Node_Str");
        pid=0;
      }
 else       if (po.getExitValue() == 0) {
        String output=po.getOutput();
        String[] lines=output.split("String_Node_Str");
        pid=Integer.parseInt(lines[lines.length - 1]);
      }
 else {
        if (timer > MAX_WAIT_FOR_SSH) {
          throw new InitNodeException("String_Node_Str" + name + "String_Node_Str"+ user+ "String_Node_Str"+ "String_Node_Str"+ po.getOutput()+ "String_Node_Str"+ "String_Node_Str"+ po.getError()+ "String_Node_Str");
        }
        logger.debug("String_Node_Str" + name + "String_Node_Str");
      }
    }
    long delay=WAIT_TIME_UNIT;
    long totalWait=0;
    logger.debug("String_Node_Str");
    CommandCheckWorker cmd=new CommandCheckWorker(DEPLOYMENT_ID,name);
    while ((!workerIsReady) && (totalWait < MAX_WAIT_FOR_INIT) && !toStop) {
      try {
        logger.debug("String_Node_Str" + delay);
        Thread.sleep(delay);
      }
 catch (      InterruptedException ie) {
        Thread.currentThread().interrupt();
      }
      if (!workerIsReady) {
        if (debug) {
          logger.debug("String_Node_Str" + name);
        }
        Connection c=NIOAdaptor.tm.startConnection(n);
        c.sendCommand(cmd);
        c.receive();
        c.finishConnection();
        totalWait+=delay;
        delay=(delay < 3900) ? delay * 2 : 4000;
      }
    }
    logger.debug("String_Node_Str" + name + "String_Node_Str");
    if (!workerIsReady) {
      ++port;
    }
 else {
      try {
        Runtime.getRuntime().addShutdownHook(new Ender(this,nw,pid));
      }
 catch (      IllegalStateException e) {
        logger.warn("String_Node_Str",e);
      }
      return n;
    }
  }
  if (toStop) {
    String msg="String_Node_Str" + name + "String_Node_Str";
    logger.warn(msg);
    throw new InitNodeException(msg);
  }
 else   if (!workerIsReady) {
    String msg="String_Node_Str" + name + "String_Node_Str"+ user+ "String_Node_Str";
    logger.warn(msg);
    throw new InitNodeException(msg);
  }
 else {
    String msg="String_Node_Str" + name + "String_Node_Str"+ user+ "String_Node_Str";
    logger.warn(msg);
    throw new InitNodeException(msg);
  }
}