This is an automated email from the ASF dual-hosted git repository. imaxon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 902f63c6683cee08c6340a6a6fe007277722d1be Author: Michael Blow <mb...@apache.org> AuthorDate: Sun Apr 25 10:52:25 2021 -0400 [NO ISSUE][HYR][HTTP] Set thread name on interruptable stream handler Change-Id: I26b718cb0373c6c4d04d7fb0666de472c0419b29 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11183 Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Hussain Towaileb <hussai...@gmail.com> --- .../main/java/org/apache/hyracks/http/server/utils/HttpUtil.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java index 01baa69..4c0942b 100644 --- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java +++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/utils/HttpUtil.java @@ -191,11 +191,13 @@ public class HttpUtil { } public static void handleStreamInterruptibly(CloseableHttpResponse response, - ThrowingConsumer<Reader> streamProcessor, ExecutorService executor, Supplier<String> taskDescription) + ThrowingConsumer<Reader> streamProcessor, ExecutorService executor, Supplier<String> descriptionSupplier) throws IOException, InterruptedException, ExecutionException { // we have to consume the stream in a separate thread, as it not stop on interrupt; we need to // instead close the connection to achieve the interrupt + String description = descriptionSupplier.get(); Future<Void> readFuture = executor.submit(() -> { + Thread.currentThread().setName(description); InputStreamReader reader = new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8); streamProcessor.process(new Reader() { @Override @@ -219,10 +221,10 @@ public class HttpUtil { try { readFuture.get(1, TimeUnit.SECONDS); } catch (TimeoutException te) { - LOGGER.warn("{} did not exit on stream close due to interrupt after 1s", taskDescription); + LOGGER.warn("{} did not exit on stream close due to interrupt after 1s", description); readFuture.cancel(true); } catch (ExecutionException ee) { - LOGGER.debug("ignoring exception awaiting aborted {} shutdown", taskDescription, ee); + LOGGER.debug("ignoring exception awaiting aborted {} shutdown", description, ee); } throw ex; }