This one is very confusing...
In a test with a MergeJoin and external sort, operators are stacked something like this:
Using the injector to force a OOM in spill, the external sort threw a UserException up the stack. This was handed by:
Which does the following:
But, the exceptionState is set, so we end up throwing an IllegalStateException during cleanup.
Seems the code should agree: if next( ) will be called during cleanup, then next( ) should gracefully handle that case.