rvesse commented on code in PR #3464:
URL: https://github.com/apache/jena/pull/3464#discussion_r2372274268
##########
jena-arq/src/main/java/org/apache/jena/http/AsyncHttpRDF.java:
##########
@@ -179,10 +181,12 @@ public static <T> T getOrElseThrow(CompletableFuture<T>
cf) {
IO.exception((IOException)cause);
}
}
+ ex.addSuppressed(new RuntimeException("Passed through here."));
Review Comment:
Again seems like leftover debugging code?
##########
jena-arq/src/main/java/org/apache/jena/http/HttpLib.java:
##########
@@ -640,25 +650,53 @@ public static HttpResponse<InputStream>
executeJDK(HttpClient httpClient, HttpRe
* @return HttpResponse
*/
public static <T> HttpResponse<T> executeJDK(HttpClient httpClient,
HttpRequest httpRequest, BodyHandler<T> bodyHandler) {
- try {
- // This is the one place all HTTP requests go through.
- logRequest(httpRequest);
- HttpResponse<T> httpResponse = httpClient.send(httpRequest,
bodyHandler);
- logResponse(httpResponse);
- return httpResponse;
- //} catch (HttpTimeoutException ex) {
- } catch (IOException | InterruptedException ex) {
- if ( ex.getMessage() != null ) {
- // This is silly.
- // Rather than an HTTP exception, bad authentication becomes
IOException("too many authentication attempts");
- // or IOException("No credentials provided") if the
authenticator decides to return null.
- if ( ex.getMessage().contains("too many authentication
attempts") ||
- ex.getMessage().contains("No credentials provided") ) {
- throw new HttpException(401, HttpSC.getMessage(401));
+ return AsyncHttpRDF.getOrElseThrow(executeJDKAsync(httpClient,
httpRequest, bodyHandler));
+ }
+
+ /**
+ * Execute request and return a {@code HttpResponse<InputStream>} response.
+ * Status codes have not been handled. The response can be passed to
+ * {@link #handleResponseInputStream(HttpResponse)} which will convert
non-2xx
+ * status code to {@link HttpException HttpExceptions}.
+ *
+ * @param httpClient
+ * @param httpRequest
+ * @return HttpResponse
+ */
+ public static CompletableFuture<HttpResponse<InputStream>>
executeJDKAsync(HttpClient httpClient, HttpRequest httpRequest) {
+ return executeAsync(httpClient, httpRequest,
BodyHandlers.ofInputStream());
+ }
+
+ public static <T> CompletableFuture<HttpResponse<T>>
executeJDKAsync(HttpClient httpClient, HttpRequest httpRequest, BodyHandler<T>
bodyHandler) {
+ // This is the one place all HTTP requests go through.
+ logRequest(httpRequest);
+ CompletableFuture<HttpResponse<T>> future =
httpClient.sendAsync(httpRequest, bodyHandler)
+ .thenApply(httpResponse -> {
+ logResponse(httpResponse);
+ return httpResponse;
+ })
+ .exceptionally(ex -> {
+ Throwable cause = ex instanceof CompletionException ?
ex.getCause() : ex;
+ if (cause instanceof IOException) {
+ if ( ex.getMessage() != null ) {
+ // This is silly.
+ // Rather than an HTTP exception, bad authentication
becomes IOException("too many authentication attempts");
+ // or IOException("No credentials provided") if the
authenticator decides to return null.
+ if ( ex.getMessage().contains("too many authentication
attempts") ||
+ ex.getMessage().contains("No credentials provided")
) {
+ throw new HttpException(401,
HttpSC.getMessage(401));
+ }
+ }
+ // Note: Can't reuse AsyncHttpRDF.handleRuntimeException
because of this HttpException.
+ throw new HttpException(httpRequest.method()+"
"+httpRequest.uri().toString(), cause);
+ } else if (cause instanceof RuntimeException re) {
+ re.addSuppressed(new RuntimeException("Passed through
here."));
Review Comment:
Again debug statement?
##########
jena-arq/src/main/java/org/apache/jena/update/UpdateProcessor.java:
##########
@@ -26,6 +26,19 @@
*/
public interface UpdateProcessor
{
+ /**
+ * The update request associated with this update execution. May be null.
+ */
+ default public UpdateRequest getUpdateRequest() { return null; }
+
+ /**
+ * The update request as a string. May be null.
+ * The string may contain syntax extensions that can not be parsed by Jena.
+ * If {@code getUpdateRequest()} is not null then the string returned by
this method
Review Comment:
```suggestion
* If {@link #getUpdateRequest()} is not null then the string returned
by this method
```
##########
jena-arq/src/main/java/org/apache/jena/http/AsyncHttpRDF.java:
##########
@@ -167,8 +167,10 @@ public static <T> T getOrElseThrow(CompletableFuture<T>
cf) {
} catch (CompletionException ex) {
if ( ex.getCause() != null ) {
Throwable cause = ex.getCause();
- if ( cause instanceof RuntimeException )
+ if ( cause instanceof RuntimeException ) {
+ cause.addSuppressed(new RuntimeException("Passed through
here."));
Review Comment:
Leftover debug statement?
--
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]