Skip to content

Commit

Permalink
HADOOP-12831. LocalFS/FSOutputSummer NPEs in constructor if bytes per…
Browse files Browse the repository at this point in the history
… checksum set to 0 (Mingliang Liu via gtcarrera9)
  • Loading branch information
gtCarrera committed Feb 28, 2016
1 parent 03cfb45 commit 7545ce6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hadoop-common-project/hadoop-common/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -61,6 +62,9 @@ public void setConf(Configuration conf) {
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,29 @@ public void testRenameFileIntoDirFile() throws Exception {
}


@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);
Expand Down

0 comments on commit 7545ce6

Please sign in to comment.