The queue.poll() invocation there yields no exception but null when the timeout elapses. This causes the following issues:
- hasNext() returning true when in reality no element is available
- next() returning a non-deterministic number of null elements tripping up processing of the query results, e.g.
- next() failing with NoSuchElementException although the caller previously checked hasNext() == true (next() calls hasNext() again and can observe a different value than the caller, like the end-of-query sentinel), e.g.