Skip to content

Commit

Permalink
fix ExecutorService not properly shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
youssef committed Sep 14, 2020
1 parent ac23430 commit b02c062
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/eternitywall/ots/Esplora.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> future = Executors.newSingleThreadExecutor().submit(task);
final ExecutorService executor = Executors.newSingleThreadExecutor();
final Future<Response> future = executor.submit(task);
final Response take = future.get();
executor.shutdown();
if (!take.isOk())
throw new Exception();

Expand All @@ -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<Response> future = Executors.newSingleThreadExecutor().submit(task);
final ExecutorService executor = Executors.newSingleThreadExecutor();
final Future<Response> future = executor.submit(task);
final Response take = future.get();
executor.shutdown();
if (!take.isOk())
throw new Exception();
final String blockHash = take.getString();
Expand Down

0 comments on commit b02c062

Please sign in to comment.