Skip to content

Commit

Permalink
BuildCheckpoints: Fix possible resource leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
sj authored and Andreas Schildbach committed Jul 29, 2017
1 parent 40c26b5 commit 759156c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/src/main/java/org/bitcoinj/tools/BuildCheckpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,14 @@ private static void writeTextualCheckpoints(TreeMap<Integer, StoredBlock> checkp
}

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)) {
Expand Down

0 comments on commit 759156c

Please sign in to comment.