hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [15/50] [abbrv] hadoop git commit: HADOOP-11891. OsSecureRandom should lazily fill its reservoir (asuresh)
Date Mon, 04 May 2015 20:04:34 GMT
HADOOP-11891. OsSecureRandom should lazily fill its reservoir (asuresh)


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

Branch: refs/heads/YARN-2928
Commit: 6f6b313bc072a8be7663e51a21a955b70240376d
Parents: 9840141
Author: Arun Suresh <asuresh@apache.org>
Authored: Thu Apr 30 13:59:43 2015 -0700
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Mon May 4 12:58:55 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt  |  2 ++
 .../hadoop/crypto/random/OsSecureRandom.java     | 19 ++++---------------
 2 files changed, 6 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/6f6b313b/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 373b33e..d2e1d4a 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -603,6 +603,8 @@ Release 2.7.1 - UNRELEASED
     HADOOP-11802. DomainSocketWatcher thread terminates sometimes after there
     is an I/O error during requestShortCircuitShm (cmccabe)
 
+    HADOOP-11891. OsSecureRandom should lazily fill its reservoir (asuresh)
+
 Release 2.7.0 - 2015-04-20
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/6f6b313b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java
index fee4186..2010e6d 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/random/OsSecureRandom.java
@@ -58,6 +58,9 @@ public class OsSecureRandom extends Random implements Closeable, Configurable
{
   private void fillReservoir(int min) {
     if (pos >= reservoir.length - min) {
       try {
+        if (stream == null) {
+          stream = new FileInputStream(new File(randomDevPath));
+        }
         IOUtils.readFully(stream, reservoir, 0, reservoir.length);
       } catch (IOException e) {
         throw new RuntimeException("failed to fill reservoir", e);
@@ -75,21 +78,7 @@ public class OsSecureRandom extends Random implements Closeable, Configurable
{
     this.randomDevPath = conf.get(
         HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_KEY,
         HADOOP_SECURITY_SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT);
-    File randomDevFile = new File(randomDevPath);
-
-    try {
-      close();
-      this.stream = new FileInputStream(randomDevFile);
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
-
-    try {
-      fillReservoir(0);
-    } catch (RuntimeException e) {
-      close();
-      throw e;
-    }
+    close();
   }
 
   @Override


Mime
View raw message