private static <R> boolean needToWait(final QueryResult<R> queryResult) {
        return queryResult.isFailure()
            && (
            FailureReason.NOT_UP_TO_BOUND.equals(queryResult.getFailureReason())
                || FailureReason.NOT_PRESENT.equals(queryResult.getFailureReason()));
    }
Repeatedly runs the query until the response is valid and then return the response.
<p>
Validity in this case means that the response position is up to the specified bound.
<p>
Once position bounding is generally supported, we should migrate tests to wait on the
expected response position.
streams/src/test/java/org/apache/kafka/streams/integration/utils/IntegrationTestUtils.java