Program: 95670
Project: 95670
Buggy source:
/** 
 * Waits <code>timeMillSec</code> if the application activates a window with the given title.
 * @param title the title
 * @param operator the comparing operator
 * @param pTimeout the time in ms
 * @param delay delay after the window is activated
 */
public void rcWaitForWindowActivation(final String title,String operator,int pTimeout,int delay){
  Stage s=null;
  try {
    long timeout=pTimeout;
    long done=System.currentTimeMillis() + timeout;
    long now;
    do {
      s=getStageByTitle(title,operator);
      now=System.currentTimeMillis();
      timeout=done - now;
      Thread.sleep(50);
    }
 while (timeout > 0 && s == null);
  }
 catch (  InterruptedException e) {
    throw new RobotException(e);
  }
  if (s == null) {
    log.error("String_Node_Str" + title + "String_Node_Str"+ operator);
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
  }
  final Stage stage=s;
  final CountDownLatch signal=new CountDownLatch(1);
  final ChangeListener<Boolean> focusListener=new ChangeListener<Boolean>(){
    @Override public void changed(    ObservableValue<? extends Boolean> observable,    Boolean oldValue,    Boolean newValue){
      if (newValue) {
        signal.countDown();
      }
    }
  }
;
  boolean isFocused=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      if (!stage.isFocused()) {
        stage.focusedProperty().addListener(focusListener);
        return false;
      }
      return true;
    }
  }
);
  if (isFocused) {
    try {
      signal.await(pTimeout,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
    }
 finally {
      stage.focusedProperty().removeListener(focusListener);
    }
    boolean result=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return stage.isFocused();
      }
    }
);
    if (!result) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.TIMEOUT_EXPIRED));
    }
  }
  TimeUtil.delay(delay);
}

Fixed version (ground truth):
/** 
 * Waits <code>timeMillSec</code> if the application activates a window with the given title.
 * @param title the title
 * @param operator the comparing operator
 * @param pTimeout the time in ms
 * @param delay delay after the window is activated
 */
public void rcWaitForWindowActivation(final String title,String operator,int pTimeout,int delay){
  final Stage stage=getStageByTitle(title,operator);
  if (stage == null) {
    log.error("String_Node_Str" + title + "String_Node_Str"+ operator);
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
  }
  final CountDownLatch signal=new CountDownLatch(1);
  final ChangeListener<Boolean> focusListener=new ChangeListener<Boolean>(){
    @Override public void changed(    ObservableValue<? extends Boolean> observable,    Boolean oldValue,    Boolean newValue){
      if (newValue) {
        signal.countDown();
      }
    }
  }
;
  boolean isFocused=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      if (!stage.isFocused()) {
        stage.focusedProperty().addListener(focusListener);
        return false;
      }
      return true;
    }
  }
);
  if (isFocused) {
    try {
      signal.await(pTimeout,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
    }
 finally {
      stage.focusedProperty().removeListener(focusListener);
    }
    boolean result=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return stage.isFocused();
      }
    }
);
    if (!result) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.TIMEOUT_EXPIRED));
    }
  }
  TimeUtil.delay(delay);
}