Procházet zdrojové kódy

HADOOP-7032. Assert type constraints in the FileStatus constructor. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1035147 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins před 14 roky
rodič
revize
ee08b2c803
2 změnil soubory, kde provedl 7 přidání a 0 odebrání
  1. 2 0
      CHANGES.txt
  2. 5 0
      src/java/org/apache/hadoop/fs/FileStatus.java

+ 2 - 0
CHANGES.txt

@@ -175,6 +175,8 @@ Trunk (unreleased changes)
 
     HADOOP-7034. Add TestPath tests to cover dot, dot dot, and slash normalization. (eli)
 
+    HADOOP-7032. Assert type constraints in the FileStatus constructor. (eli)
+
   OPTIMIZATIONS
 
     HADOOP-6884. Add LOG.isDebugEnabled() guard for each LOG.debug(..).

+ 5 - 0
src/java/org/apache/hadoop/fs/FileStatus.java

@@ -85,6 +85,11 @@ public class FileStatus implements Writable, Comparable {
     this.group = (group == null) ? "" : group;
     this.symlink = symlink;
     this.path = path;
+    // The variables isdir and symlink indicate the type:
+    // 1. isdir implies directory, in which case symlink must be null.
+    // 2. !isdir implies a file or symlink, symlink != null implies a
+    //    symlink, otherwise it's a file.
+    assert (isdir && symlink == null) || !isdir;
   }
 
   /**