Program: 95509
Project: 95509
Buggy source:
/** 
 * Waits <code>timeMillSec</code> if the application opens 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 shown
 */
public void rcWaitForWindow(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.COMP_NOT_FOUND));
  }
  final Stage stage=s;
  final CountDownLatch signal=new CountDownLatch(1);
  final EventHandler<WindowEvent> showHandler=new EventHandler<WindowEvent>(){
    @Override public void handle(    WindowEvent event){
      signal.countDown();
    }
  }
;
  boolean isShowing=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      if (!stage.isShowing()) {
        stage.addEventFilter(WindowEvent.WINDOW_SHOWN,showHandler);
        return false;
      }
      return true;
    }
  }
);
  if (!isShowing) {
    try {
      signal.await(pTimeout,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
    }
 finally {
      stage.removeEventFilter(WindowEvent.WINDOW_SHOWN,showHandler);
    }
    boolean result=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return stage.isShowing();
      }
    }
);
    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 opens 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 shown
 */
public void rcWaitForWindow(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.COMP_NOT_FOUND));
  }
  final Stage stage=s;
  final CountDownLatch signal=new CountDownLatch(1);
  final EventHandler<WindowEvent> showHandler=new EventHandler<WindowEvent>(){
    @Override public void handle(    WindowEvent event){
      signal.countDown();
    }
  }
;
  boolean isShowing=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      if (!stage.isShowing()) {
        stage.addEventFilter(WindowEvent.WINDOW_SHOWN,showHandler);
        return false;
      }
      return true;
    }
  }
);
  if (!isShowing) {
    try {
      signal.await(pTimeout,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
    }
 finally {
      stage.removeEventFilter(WindowEvent.WINDOW_SHOWN,showHandler);
    }
  }
  boolean result=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      return stage.isShowing();
    }
  }
);
  if (!result) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.TIMEOUT_EXPIRED));
  }
  TimeUtil.delay(delay);
}