HADOOP-13288. Guard null stats key in FileSystemStorageStatistics (Mingliang Liu via Colin P. McCabe)
(cherry picked from commit8c1f81d4bf
) (cherry picked from commit14df17383c
)
This commit is contained in:
parent
c610b60331
commit
c5dafb4ad7
|
@ -20,6 +20,7 @@ package org.apache.hadoop.fs;
|
|||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
import org.apache.hadoop.fs.FileSystem.Statistics.StatisticsData;
|
||||
|
@ -77,6 +78,9 @@ public class FileSystemStorageStatistics extends StorageStatistics {
|
|||
}
|
||||
|
||||
private static Long fetch(StatisticsData data, String key) {
|
||||
Preconditions.checkArgument(key != null,
|
||||
"The stat key of FileSystemStorageStatistics should not be null!");
|
||||
|
||||
switch (key) {
|
||||
case "bytesRead":
|
||||
return data.getBytesRead();
|
||||
|
@ -95,6 +99,10 @@ public class FileSystemStorageStatistics extends StorageStatistics {
|
|||
|
||||
FileSystemStorageStatistics(String name, FileSystem.Statistics stats) {
|
||||
super(name);
|
||||
Preconditions.checkArgument(stats != null,
|
||||
"FileSystem.Statistics can not be null");
|
||||
Preconditions.checkArgument(stats.getData() != null,
|
||||
"FileSystem.Statistics can not have null data");
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue