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();