diff --git a/tools/src/main/java/org/bitcoinj/tools/BuildCheckpoints.java b/tools/src/main/java/org/bitcoinj/tools/BuildCheckpoints.java index 51b28343a..1e54d1257 100644 --- a/tools/src/main/java/org/bitcoinj/tools/BuildCheckpoints.java +++ b/tools/src/main/java/org/bitcoinj/tools/BuildCheckpoints.java @@ -211,7 +211,14 @@ public class BuildCheckpoints { } private static void sanityCheck(File file, int expectedSize) throws IOException { - CheckpointManager manager = new CheckpointManager(params, new FileInputStream(file)); + FileInputStream fis = new FileInputStream(file); + CheckpointManager manager; + try { + manager = new CheckpointManager(params, fis); + } finally { + fis.close(); + } + checkState(manager.numCheckpoints() == expectedSize); if (params.getId().equals(NetworkParameters.ID_MAINNET)) {