Program: 95510
Project: 95510
Buggy source:
/** 
 * Waits <code>timeMillSec</code> if the application closes (or hides) a window with the given title. If no window with the given title can be found, then it is assumed that the window has already closed.
 * @param title the title
 * @param operator the comparing operator
 * @param pTimeout the time in ms
 * @param delay delay after the window is closed
 */
public void rcWaitForWindowToClose(final String title,final String operator,int pTimeout,int delay){
  final Stage s=getStageByTitle(title,operator);
  if (s == null) {
    return;
  }
  final CountDownLatch signal=new CountDownLatch(1);
  final EventHandler<WindowEvent> closeHandler=new EventHandler<WindowEvent>(){
    @Override public void handle(    WindowEvent event){
      signal.countDown();
    }
  }
;
  boolean isClosing=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      s.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,closeHandler);
      return false;
    }
  }
);
  if (isClosing) {
    try {
      signal.await(pTimeout,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
    }
 finally {
      s.removeEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,closeHandler);
    }
    boolean result=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        final Stage tmpS=getStageByTitle(title,operator);
        return tmpS == null;
      }
    }
);
    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 closes (or hides) a window with the given title. If no window with the given title can be found, then it is assumed that the window has already closed.
 * @param title the title
 * @param operator the comparing operator
 * @param pTimeout the time in ms
 * @param delay delay after the window is closed
 */
public void rcWaitForWindowToClose(final String title,final String operator,int pTimeout,int delay){
  final Stage s=getStageByTitle(title,operator);
  if (s == null) {
    return;
  }
  final CountDownLatch signal=new CountDownLatch(1);
  final EventHandler<WindowEvent> closeHandler=new EventHandler<WindowEvent>(){
    @Override public void handle(    WindowEvent event){
      signal.countDown();
    }
  }
;
  boolean isClosing=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      if (s.isShowing()) {
        s.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,closeHandler);
        return false;
      }
 else {
        return true;
      }
    }
  }
);
  if (!isClosing) {
    try {
      signal.await(pTimeout,TimeUnit.MILLISECONDS);
    }
 catch (    InterruptedException e) {
      throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.EXECUTION_ERROR));
    }
 finally {
      s.removeEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,closeHandler);
    }
  }
  boolean result=EventThreadQueuerJavaFXImpl.invokeAndWait("String_Node_Str",new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      final Stage tmpS=getStageByTitle(title,operator);
      return tmpS == null || !tmpS.isShowing();
    }
  }
);
  if (!result) {
    throw new StepExecutionException("String_Node_Str",EventFactory.createActionError(TestErrorEvent.TIMEOUT_EXPIRED));
  }
  TimeUtil.delay(delay);
}