From b02c06256eeee47f5bf8869f52acacd321d6b844 Mon Sep 17 00:00:00 2001 From: youssef Date: Mon, 14 Sep 2020 04:14:38 +0000 Subject: [PATCH] fix ExecutorService not properly shutdown --- src/main/java/com/eternitywall/ots/Esplora.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eternitywall/ots/Esplora.java b/src/main/java/com/eternitywall/ots/Esplora.java index 2e6f919..d85dec6 100644 --- a/src/main/java/com/eternitywall/ots/Esplora.java +++ b/src/main/java/com/eternitywall/ots/Esplora.java @@ -23,8 +23,10 @@ public class Esplora { public static BlockHeader block(final String hash) throws Exception { final URL url = new URL(esploraUrl + "/block/" + hash); final Request task = new Request(url); - final Future future = Executors.newSingleThreadExecutor().submit(task); + final ExecutorService executor = Executors.newSingleThreadExecutor(); + final Future future = executor.submit(task); final Response take = future.get(); + executor.shutdown(); if (!take.isOk()) throw new Exception(); @@ -50,8 +52,10 @@ public static BlockHeader block(final String hash) throws Exception { public static String blockHash(final Integer height) throws Exception { final URL url = new URL(esploraUrl + "/block-height/" + height); final Request task = new Request(url); - final Future future = Executors.newSingleThreadExecutor().submit(task); + final ExecutorService executor = Executors.newSingleThreadExecutor(); + final Future future = executor.submit(task); final Response take = future.get(); + executor.shutdown(); if (!take.isOk()) throw new Exception(); final String blockHash = take.getString();