/**
  * Cleans up the window state if the provided {@link TriggerResult} requires so, or if it is time
  * to do so (see {@link #isCleanupTime(Window, long)}). The caller must ensure that the correct
  * key is set in the state backend and the context object.
  */
 private void cleanup(
     W window, AppendingState<IN, ACC> windowState, MergingWindowSet<W> mergingWindows)
     throws Exception {
   windowState.clear();
   if (mergingWindows != null) {
     mergingWindows.retireWindow(window);
   }
   context.clear();
   deleteCleanupTimer(window);
 }
  private void cleanup(
      W window, ListState<StreamRecord<IN>> windowState, MergingWindowSet<W> mergingWindows)
      throws Exception {

    windowState.clear();
    if (mergingWindows != null) {
      mergingWindows.retireWindow(window);
    }
    context.clear();
    deleteCleanupTimer(window);
  }