hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oz...@apache.org
Subject hadoop git commit: HADOOP-10615. FileInputStream in JenkinsHash#main() is never closed. Contributed by Chen He.
Date Thu, 16 Jul 2015 05:12:45 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 3ec0a0444 -> 111e6a3fd


HADOOP-10615. FileInputStream in JenkinsHash#main() is never closed. Contributed by Chen He.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/111e6a3f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/111e6a3f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/111e6a3f

Branch: refs/heads/trunk
Commit: 111e6a3fdf613767782817836c42810bf2bda5e8
Parents: 3ec0a04
Author: Tsuyoshi Ozawa <ozawa@apache.org>
Authored: Thu Jul 16 14:08:31 2015 +0900
Committer: Tsuyoshi Ozawa <ozawa@apache.org>
Committed: Thu Jul 16 14:08:31 2015 +0900

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt      |  3 +++
 .../org/apache/hadoop/util/hash/JenkinsHash.java     | 15 ++++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/111e6a3f/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 3d64156..9bb7a26 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -961,6 +961,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

http://git-wip-us.apache.org/repos/asf/hadoop/blob/111e6a3f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/hash/JenkinsHash.java
----------------------------------------------------------------------
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 bf48913..f3895d0 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));
   }
 }


Mime
View raw message