This follows on from
JENA-2139. It is the more general case.
This is query 1 from the report from: Cristóbal Miranda on users@.
Query cancellation happens when an async timeout call queryIterator.abort in QueryExecutionBase.
But queryIterator is only set after the execution tree of iterators has been built, bottom-up.
If building takes a long time, the timeout callback can not call .abort.
The code needs to have a flag setup so it can be set at any time.
The mechanism added in Jena-2139, and similar code in QueryIterSort, QueryIterGroup and QueryIterTopN, which uses delayed initialization is better when this is possible. However, sometimes it is not easy to know when in the initialization phase.
One possibility is adding this to the ExecutionContext which exists and is passed to all query iterators during the setup phase.
QueryExecutionBase is being renamed as QueryExecDataset in PR#1003 as part of
JENA-2128 in JENA-2125.