hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject hadoop git commit: HADOOP-13140. FileSystem#initialize must not attempt to create StorageStatistics objects with null or empty schemes (Mingliang Liu via cmccabe)
Date Wed, 18 May 2016 16:19:34 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 8a9ecb758 -> f2c1d9181


HADOOP-13140. FileSystem#initialize must not attempt to create StorageStatistics objects with
null or empty schemes (Mingliang Liu via cmccabe)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f2c1d918
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f2c1d918
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f2c1d918

Branch: refs/heads/trunk
Commit: f2c1d9181f80e53890b50309b15c9ea37cb24987
Parents: 8a9ecb7
Author: Colin Patrick Mccabe <cmccabe@cloudera.com>
Authored: Wed May 18 09:15:32 2016 -0700
Committer: Colin Patrick Mccabe <cmccabe@cloudera.com>
Committed: Wed May 18 09:15:32 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/hadoop/fs/FileSystem.java   | 11 ++++++++++-
 .../org/apache/hadoop/fs/GlobalStorageStatistics.java    |  5 ++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f2c1d918/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
index 574027e..9e13a7a 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
@@ -75,6 +75,7 @@ import org.apache.htrace.core.TraceScope;
 
 import com.google.common.annotations.VisibleForTesting;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.*;
 
 /****************************************************************
@@ -211,7 +212,13 @@ public abstract class FileSystem extends Configured implements Closeable
{
    * @param conf the configuration
    */
   public void initialize(URI name, Configuration conf) throws IOException {
-    statistics = getStatistics(name.getScheme(), getClass());    
+    final String scheme;
+    if (name.getScheme() == null || name.getScheme().isEmpty()) {
+      scheme = getDefaultUri(conf).getScheme();
+    } else {
+      scheme = name.getScheme();
+    }
+    statistics = getStatistics(scheme, getClass());
     resolveSymlinks = conf.getBoolean(
         CommonConfigurationKeys.FS_CLIENT_RESOLVE_REMOTE_SYMLINKS_KEY,
         CommonConfigurationKeys.FS_CLIENT_RESOLVE_REMOTE_SYMLINKS_DEFAULT);
@@ -3590,6 +3597,8 @@ public abstract class FileSystem extends Configured implements Closeable
{
   @Deprecated
   public static synchronized Statistics getStatistics(final String scheme,
       Class<? extends FileSystem> cls) {
+    checkArgument(scheme != null,
+        "No statistics is allowed for a file system with null scheme!");
     Statistics result = statisticsTable.get(cls);
     if (result == null) {
       final Statistics newStats = new Statistics(scheme);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f2c1d918/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobalStorageStatistics.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobalStorageStatistics.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobalStorageStatistics.java
index f22e78c..7502965 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobalStorageStatistics.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobalStorageStatistics.java
@@ -23,6 +23,7 @@ import java.util.NavigableMap;
 import java.util.NoSuchElementException;
 import java.util.TreeMap;
 
+import com.google.common.base.Preconditions;
 import org.apache.hadoop.classification.InterfaceAudience;
 
 /**
@@ -55,7 +56,7 @@ public enum GlobalStorageStatistics {
    *                      null if there is none.
    */
   public synchronized StorageStatistics get(String name) {
-    return map.get(name);
+    return name == null ? null : map.get(name);
   }
 
   /**
@@ -70,6 +71,8 @@ public enum GlobalStorageStatistics {
    */
   public synchronized StorageStatistics put(String name,
       StorageStatisticsProvider provider) {
+    Preconditions.checkNotNull(name,
+        "Storage statistics can not have a null name!");
     StorageStatistics stats = map.get(name);
     if (stats != null) {
       return stats;


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message