HDFS-11476. Fix NPE in FsDatasetImpl#checkAndUpdate. Contributed by Xiaobing Zhou.

This commit is contained in:
Jing Zhao 2017-03-03 13:31:20 -08:00
parent 2148b83993
commit ac5ae0065a

View File

@ -2282,12 +2282,14 @@ public void checkAndUpdate(String bpid, long blockId, File diskFile,
if (memBlockInfo.getGenerationStamp() != diskGS) { if (memBlockInfo.getGenerationStamp() != diskGS) {
File memMetaFile = FsDatasetUtil.getMetaFile(diskFile, File memMetaFile = FsDatasetUtil.getMetaFile(diskFile,
memBlockInfo.getGenerationStamp()); memBlockInfo.getGenerationStamp());
if (memMetaFile.exists()) { if (fileIoProvider.exists(vol, memMetaFile)) {
if (memMetaFile.compareTo(diskMetaFile) != 0) { String warningPrefix = "Metadata file in memory "
LOG.warn("Metadata file in memory "
+ memMetaFile.getAbsolutePath() + memMetaFile.getAbsolutePath()
+ " does not match file found by scan " + " does not match file found by scan ";
+ (diskMetaFile == null? null: diskMetaFile.getAbsolutePath())); if (!diskMetaFileExists) {
LOG.warn(warningPrefix + "null");
} else if (memMetaFile.compareTo(diskMetaFile) != 0) {
LOG.warn(warningPrefix + diskMetaFile.getAbsolutePath());
} }
} else { } else {
// Metadata file corresponding to block in memory is missing // Metadata file corresponding to block in memory is missing