Aklakan commented on code in PR #3464:
URL: https://github.com/apache/jena/pull/3464#discussion_r2394815294


##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -624,22 +649,71 @@ private static void logQuery(String queryString, 
HttpRequest request) {}
     /**
      * Cancel query evaluation
      */
-    public void cancel() {
-        closed = true;
-    }
-
     @Override
     public void abort() {
-        try {
-            close();
-        } catch (Exception ex) {
-            Log.warn(this, "Error during abort", ex);
+        // Setting abort to true causes the next read from
+        // retainedConnectionView (if already created) to
+        // fail with a QueryCancelledException.
+        isAborted = true;
+        if (cancelFutureOnAbort) {
+            cancelFuture(future);
+        }
+    }
+
+    private InputStream registerInputStream(HttpResponse<InputStream> 
httpResponse) {
+        InputStream in = HttpLib.getInputStream(httpResponse);
+        registerInputStream(in);
+        return in;
+    }
+
+    /**
+     * Set the given input stream as the 'retainedConnection' and create a 
corresponding
+     * asynchronously abortable 'retainedConnectionView'. The latter is 
returned.
+     * If execution was already aborted then a {@link QueryCancelledException} 
is raised.
+     */
+    private InputStream registerInputStream(InputStream in) {
+        synchronized (abortLock) {
+            this.retainedConnection = in;
+            // Note: Used ProxyInputStream because the ctor of 
CloseShieldInputStream is deprecated.
+            this.retainedConnectionView = new ProxyInputStream(in) {
+                @Override
+                protected void beforeRead(int n) throws IOException {
+                    if (isAborted) {
+                        throw new QueryCancelledException();

Review Comment:
   Oops, snippet was modified during cleanup - resolving here.



-- 
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]

Reply via email to