hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtcarre...@apache.org
Subject hadoop git commit: HADOOP-12831. LocalFS/FSOutputSummer NPEs in constructor if bytes per checksum set to 0 (Mingliang Liu via gtcarrera9)
Date Sun, 28 Feb 2016 06:02:19 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 03cfb454f -> 7545ce663


HADOOP-12831. LocalFS/FSOutputSummer NPEs in constructor if bytes per checksum set to 0 (Mingliang
Liu via gtcarrera9)


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

Branch: refs/heads/trunk
Commit: 7545ce6636066a05763744a817878e03ee87f456
Parents: 03cfb45
Author: Li Lu <gtcarrera9@apache.org>
Authored: Sat Feb 27 21:59:03 2016 -0800
Committer: Li Lu <gtcarrera9@apache.org>
Committed: Sat Feb 27 21:59:03 2016 -0800

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 +++
 .../apache/hadoop/fs/ChecksumFileSystem.java    |  4 ++++
 .../hadoop/fs/TestChecksumFileSystem.java       | 23 ++++++++++++++++++++
 3 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7545ce66/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 b8ae8df..9f95221 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -780,6 +780,9 @@ Release 2.8.0 - UNRELEASED
     (Larry McCay via cnauroth)
 
   IMPROVEMENTS
+    
+    HADOOP-12831. LocalFS/FSOutputSummer NPEs in constructor if bytes per checksum 
+    set to 0 (Mingliang Liu via gtcarrera9)
 
     HADOOP-12458. Retries is typoed to spell Retires in parts of
     hadoop-yarn and hadoop-common

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7545ce66/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
index 3b8ecea..c19be3d 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.nio.channels.ClosedChannelException;
 import java.util.Arrays;
 
+import com.google.common.base.Preconditions;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
@@ -61,6 +62,9 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
     if (conf != null) {
       bytesPerChecksum = conf.getInt(LocalFileSystemConfigKeys.LOCAL_FS_BYTES_PER_CHECKSUM_KEY,
 		                     LocalFileSystemConfigKeys.LOCAL_FS_BYTES_PER_CHECKSUM_DEFAULT);
+      Preconditions.checkState(bytesPerChecksum > 0,
+          "bytes per checksum should be positive but was %s",
+          bytesPerChecksum);
     }
   }
   

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7545ce66/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
index 0c24ad5..923d219 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
@@ -228,6 +228,29 @@ public class TestChecksumFileSystem {
   }
 
 
+  @Test
+  public void testSetConf() {
+    Configuration conf = new Configuration();
+
+    conf.setInt(LocalFileSystemConfigKeys.LOCAL_FS_BYTES_PER_CHECKSUM_KEY, 0);
+    try {
+      localFs.setConf(conf);
+      fail("Should have failed because zero bytes per checksum is invalid");
+    } catch (IllegalStateException ignored) {
+    }
+
+    conf.setInt(LocalFileSystemConfigKeys.LOCAL_FS_BYTES_PER_CHECKSUM_KEY, -1);
+    try {
+      localFs.setConf(conf);
+      fail("Should have failed because negative bytes per checksum is invalid");
+    } catch (IllegalStateException ignored) {
+    }
+
+    conf.setInt(LocalFileSystemConfigKeys.LOCAL_FS_BYTES_PER_CHECKSUM_KEY, 512);
+    localFs.setConf(conf);
+
+  }
+
   void verifyRename(Path srcPath, Path dstPath, boolean dstIsDir)
       throws Exception { 
     localFs.delete(srcPath,true);


Mime
View raw message