afs commented on PR #2395: URL: https://github.com/apache/jena/pull/2395#issuecomment-2057054016
Improving this is good to have. To try my understanding out, I wrote some tests. Maybe I'm misunderstanding the intention. Whole file: [TestCancelQueryAFS.java.txt](https://github.com/apache/jena/files/14980629/TestCancelQueryAFS.java.txt) It is what happens for CONSTRUCT et al, and whether abort before exec does cancel when there is no iteration. `test_cancel_select_1()` does not cancel. It does not touch the iterator. `test_cancel_select_2()` does cancel. In the tests file there are tests for CONSTRUCT and ASK. I haven't figured out why these don't cancel - I would have thought the iterator was run. There is also a copy of test_Cancel_API_5 and variations to show I am runnign the PR code :smile: ```java @Test public void test_cancel_select_1() { cancellationTest("SELECT * {}", exec->exec.select()); } @Test public void test_cancel_select_2() { cancellationTest("SELECT * {}", exec->exec.select().hasNext()); } . . . static void cancellationTest(String queryString, Consumer<QueryExec> execAction) { DatasetGraph dsg = DatasetGraphFactory.createTxnMem(); dsg.add(SSE.parseQuad("(_ :s :p :o)")); try(QueryExec aExec = QueryExec.dataset(dsg).query(queryString).build()) { aExec.abort(); assertThrows(QueryCancelledException.class, ()-> execAction.accept(aExec)); } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
