HDFS-14172. Avoid NPE when SectionName#fromString returns null. Contributed by Xiang Li.
This commit is contained in:
parent
394a9f7d5c
commit
177131793a
@ -241,8 +241,11 @@ public final class FSImageFormatProtobuf {
|
||||
summary.getCodec(), in);
|
||||
|
||||
String n = s.getName();
|
||||
|
||||
switch (SectionName.fromString(n)) {
|
||||
SectionName sectionName = SectionName.fromString(n);
|
||||
if (sectionName == null) {
|
||||
throw new IOException("Unrecognized section " + n);
|
||||
}
|
||||
switch (sectionName) {
|
||||
case NS_INFO:
|
||||
loadNameSystemSection(in);
|
||||
break;
|
||||
|
@ -156,7 +156,13 @@ class FSImageLoader {
|
||||
LOG.debug("Loading section " + s.getName() + " length: " + s.getLength
|
||||
());
|
||||
}
|
||||
switch (FSImageFormatProtobuf.SectionName.fromString(s.getName())) {
|
||||
|
||||
FSImageFormatProtobuf.SectionName sectionName
|
||||
= FSImageFormatProtobuf.SectionName.fromString(s.getName());
|
||||
if (sectionName == null) {
|
||||
throw new IOException("Unrecognized section " + s.getName());
|
||||
}
|
||||
switch (sectionName) {
|
||||
case STRING_TABLE:
|
||||
stringTable = loadStringTable(is);
|
||||
break;
|
||||
|
@ -594,7 +594,11 @@ abstract class PBImageTextWriter implements Closeable {
|
||||
is = FSImageUtil.wrapInputStreamForCompression(conf,
|
||||
summary.getCodec(), new BufferedInputStream(new LimitInputStream(
|
||||
fin, section.getLength())));
|
||||
switch (SectionName.fromString(section.getName())) {
|
||||
SectionName sectionName = SectionName.fromString(section.getName());
|
||||
if (sectionName == null) {
|
||||
throw new IOException("Unrecognized section " + section.getName());
|
||||
}
|
||||
switch (sectionName) {
|
||||
case STRING_TABLE:
|
||||
LOG.info("Loading string table");
|
||||
stringTable = FSImageLoader.loadStringTable(is);
|
||||
|
@ -326,7 +326,11 @@ public final class PBImageXmlWriter {
|
||||
summary.getCodec(), new BufferedInputStream(new LimitInputStream(
|
||||
fin, s.getLength())));
|
||||
|
||||
switch (SectionName.fromString(s.getName())) {
|
||||
SectionName sectionName = SectionName.fromString(s.getName());
|
||||
if (sectionName == null) {
|
||||
throw new IOException("Unrecognized section " + s.getName());
|
||||
}
|
||||
switch (sectionName) {
|
||||
case NS_INFO:
|
||||
dumpNameSection(is);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user