svn merge -c 1401309 FIXES: HDFS-4090. getFileChecksum() result incompatible when called against zero-byte files. (Kihwal Lee via daryn)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1401315 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3445356801
commit
96cc1ad304
|
@ -1616,6 +1616,9 @@ Release 0.23.5 - UNRELEASED
|
|||
HDFS-3224. Bug in check for DN re-registration with different storage ID
|
||||
(jlowe)
|
||||
|
||||
HDFS-4090. getFileChecksum() result incompatible when called against
|
||||
zero-byte files. (Kihwal Lee via daryn)
|
||||
|
||||
Release 0.23.4 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -1795,6 +1795,13 @@ public class DFSClient implements java.io.Closeable {
|
|||
return new MD5MD5CRC32CastagnoliFileChecksum(bytesPerCRC,
|
||||
crcPerBlock, fileMD5);
|
||||
default:
|
||||
// If there is no block allocated for the file,
|
||||
// return one with the magic entry that matches what previous
|
||||
// hdfs versions return.
|
||||
if (locatedblocks.size() == 0) {
|
||||
return new MD5MD5CRC32GzipFileChecksum(0, 0, fileMD5);
|
||||
}
|
||||
|
||||
// we should never get here since the validity was checked
|
||||
// when getCrcType() was called above.
|
||||
return null;
|
||||
|
|
|
@ -515,6 +515,21 @@ public class TestDistributedFileSystem {
|
|||
final FileChecksum webhdfs_qfoocs = webhdfs.getFileChecksum(webhdfsqualified);
|
||||
System.out.println("webhdfs_qfoocs=" + webhdfs_qfoocs);
|
||||
|
||||
//create a zero byte file
|
||||
final Path zeroByteFile = new Path(dir, "zeroByteFile" + n);
|
||||
{
|
||||
final FSDataOutputStream out = hdfs.create(zeroByteFile, false, buffer_size,
|
||||
(short)2, block_size);
|
||||
out.close();
|
||||
}
|
||||
|
||||
// verify the magic val for zero byte files
|
||||
{
|
||||
final FileChecksum zeroChecksum = hdfs.getFileChecksum(zeroByteFile);
|
||||
assertEquals(zeroChecksum.toString(),
|
||||
"MD5-of-0MD5-of-0CRC32:70bc8f4b72a86921468bf8e8441dce51");
|
||||
}
|
||||
|
||||
//write another file
|
||||
final Path bar = new Path(dir, "bar" + n);
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue