code: public void addQueryInfoStateChangeListener(StateChangeListener<QueryInfo> stateChangeListener)
      {
          AtomicBoolean done = new AtomicBoolean();
          StateChangeListener<Optional<QueryInfo>> fireOnceStateChangeListener = finalQueryInfo -> {
              if (finalQueryInfo.isPresent() && done.compareAndSet(false, true)) {
                  stateChangeListener.stateChanged(finalQueryInfo.get());
              }
          };
          finalQueryInfo.addStateChangeListener(fireOnceStateChangeListener);
      }
docs: Add a listener for the final query info.  This notification is guaranteed to be fired only once.
  Listener is always notified asynchronously using a dedicated notification thread pool so, care should
  be taken to avoid leaking {@code this} when adding a listener in a constructor.