diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index eba31b33e53..4b2d76783fd 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -475,6 +475,9 @@ Release 2.8.0 - UNRELEASED HADOOP-12200. TestCryptoStreamsWithOpensslAesCtrCryptoCodec should be skipped in non-native profile. (Masatake Iwasaki via aajisaka) + HADOOP-10615. FileInputStream in JenkinsHash#main() is never closed. + (Chen He via ozawa) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/hash/JenkinsHash.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/hash/JenkinsHash.java index bf4891378c6..f3895d02484 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/hash/JenkinsHash.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/hash/JenkinsHash.java @@ -252,13 +252,14 @@ public class JenkinsHash extends Hash { System.err.println("Usage: JenkinsHash filename"); System.exit(-1); } - FileInputStream in = new FileInputStream(args[0]); - byte[] bytes = new byte[512]; - int value = 0; - JenkinsHash hash = new JenkinsHash(); - for (int length = in.read(bytes); length > 0 ; length = in.read(bytes)) { - value = hash.hash(bytes, length, value); + try (FileInputStream in = new FileInputStream(args[0])) { + byte[] bytes = new byte[512]; + int value = 0; + JenkinsHash hash = new JenkinsHash(); + for (int length = in.read(bytes); length > 0; length = in.read(bytes)) { + value = hash.hash(bytes, length, value); + } + System.out.println(Math.abs(value)); } - System.out.println(Math.abs(value)); } }