Aklakan commented on code in PR #2822:
URL: https://github.com/apache/jena/pull/2822#discussion_r1836609039
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/UpdateExecHTTP.java:
##########
@@ -130,13 +136,40 @@ private void executePostForm(Params thisParams) {
}
private String executeUpdate(String requestURL, BodyPublisher body, String
contentType) {
- HttpRequest.Builder builder = HttpLib.requestBuilder(requestURL,
httpHeaders, -1L, null);
+ HttpRequest.Builder builder = HttpLib.requestBuilder(requestURL,
httpHeaders, timeout, timeoutUnit);
builder = contentTypeHeader(builder, contentType);
HttpRequest request = builder.POST(body).build();
logUpdate(updateString, request);
HttpResponse<InputStream> response = HttpLib.execute(httpClient,
request);
- return handleResponseRtnString(response);
+ return HttpLib.handleResponseRtnString(response,
this::setRetainedConnection);
+ }
+
+ private void setRetainedConnection(InputStream in) {
+ synchronized (cancelSignal) {
+ retainedConnection = in;
+ if (cancelSignal.get()) {
+ abort();
+ }
+ }
}
private static void logUpdate(String updateString, HttpRequest request) {}
+
+ /** Best effort that tries to close an underlying HTTP connection.
+ * May still hang waiting for the HTTP request to complete. */
+ @Override
+ public void abort() {
+ cancelSignal.set(true);
+ synchronized (cancelSignal) {
+ try {
+ InputStream in = retainedConnection;
+ if (in != null) {
+ in.close();
Review Comment:
I suppose this will just hang trying to consume any remaining data. Perhaps
a test case could be created against the Fuseki server.
--
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]