[29/50] [abbrv] hadoop git commit: HADOOP-7352. FileSystem#listStatus should throw IOE upon access error. Contributed by John Zhuge.

2016-10-21 Thread aengineer
HADOOP-7352. FileSystem#listStatus should throw IOE upon access error. 
Contributed by John Zhuge.


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

Branch: refs/heads/HDFS-7240
Commit: efdf810cf9f72d78e97e860576c64a382ece437c
Parents: 29caf6d
Author: Xiao Chen 
Authored: Tue Oct 18 18:18:43 2016 -0700
Committer: Xiao Chen 
Committed: Tue Oct 18 18:18:43 2016 -0700

--
 .../java/org/apache/hadoop/fs/FileSystem.java   | 14 +---
 .../apache/hadoop/fs/RawLocalFileSystem.java|  5 +---
 .../src/site/markdown/filesystem/filesystem.md  |  3 +++
 .../hadoop/fs/FSMainOperationsBaseTest.java | 24 +---
 .../apache/hadoop/fs/shell/TestPathData.java| 19 
 .../apache/hadoop/hdfs/web/TestTokenAspect.java |  6 ++---
 .../apache/hadoop/tools/TestDistCpWithAcls.java |  2 +-
 .../hadoop/tools/TestDistCpWithXAttrs.java  |  2 +-
 8 files changed, 54 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/efdf810c/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 cc062c4..39b5b95 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
@@ -1524,13 +1524,14 @@ public abstract class FileSystem extends Configured 
implements Closeable {
* 
* Does not guarantee to return the List of files/directories status in a
* sorted order.
+   * 
+   * Will not return null. Expect IOException upon access error.
* @param f given path
* @return the statuses of the files/directories in the given patch
-   * @throws FileNotFoundException when the path does not exist;
-   * IOException see specific implementation
+   * @throws FileNotFoundException when the path does not exist
+   * @throws IOException see specific implementation
*/
-  public abstract FileStatus[] listStatus(Path f) throws 
FileNotFoundException, 
- IOException;
+  public abstract FileStatus[] listStatus(Path f) throws IOException;
 
   /**
* Represents a batch of directory entries when iteratively listing a
@@ -1600,10 +1601,7 @@ public abstract class FileSystem extends Configured 
implements Closeable {
   private void listStatus(ArrayList results, Path f,
   PathFilter filter) throws FileNotFoundException, IOException {
 FileStatus listing[] = listStatus(f);
-if (listing == null) {
-  throw new IOException("Error accessing " + f);
-}
-
+Preconditions.checkNotNull(listing, "listStatus should not return NULL");
 for (int i = 0; i < listing.length; i++) {
   if (filter.accept(listing[i].getPath())) {
 results.add(listing[i]);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efdf810c/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
--
diff --git 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
index 0fcddcf..5e6cb05 100644
--- 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
+++ 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
@@ -466,10 +466,7 @@ public class RawLocalFileSystem extends FileSystem {
 }
 
 if (localf.isDirectory()) {
-  String[] names = localf.list();
-  if (names == null) {
-return null;
-  }
+  String[] names = FileUtil.list(localf);
   results = new FileStatus[names.length];
   int j = 0;
   for (int i = 0; i < names.length; i++) {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efdf810c/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
--
diff --git 
a/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
 
b/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
index d927b8b..063bd97 100644
--- 
a/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
+++ 

hadoop git commit: HADOOP-7352. FileSystem#listStatus should throw IOE upon access error. Contributed by John Zhuge.

2016-10-18 Thread xiao
Repository: hadoop
Updated Branches:
  refs/heads/trunk 29caf6d7d -> efdf810cf


HADOOP-7352. FileSystem#listStatus should throw IOE upon access error. 
Contributed by John Zhuge.


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

Branch: refs/heads/trunk
Commit: efdf810cf9f72d78e97e860576c64a382ece437c
Parents: 29caf6d
Author: Xiao Chen 
Authored: Tue Oct 18 18:18:43 2016 -0700
Committer: Xiao Chen 
Committed: Tue Oct 18 18:18:43 2016 -0700

--
 .../java/org/apache/hadoop/fs/FileSystem.java   | 14 +---
 .../apache/hadoop/fs/RawLocalFileSystem.java|  5 +---
 .../src/site/markdown/filesystem/filesystem.md  |  3 +++
 .../hadoop/fs/FSMainOperationsBaseTest.java | 24 +---
 .../apache/hadoop/fs/shell/TestPathData.java| 19 
 .../apache/hadoop/hdfs/web/TestTokenAspect.java |  6 ++---
 .../apache/hadoop/tools/TestDistCpWithAcls.java |  2 +-
 .../hadoop/tools/TestDistCpWithXAttrs.java  |  2 +-
 8 files changed, 54 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/efdf810c/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 cc062c4..39b5b95 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
@@ -1524,13 +1524,14 @@ public abstract class FileSystem extends Configured 
implements Closeable {
* 
* Does not guarantee to return the List of files/directories status in a
* sorted order.
+   * 
+   * Will not return null. Expect IOException upon access error.
* @param f given path
* @return the statuses of the files/directories in the given patch
-   * @throws FileNotFoundException when the path does not exist;
-   * IOException see specific implementation
+   * @throws FileNotFoundException when the path does not exist
+   * @throws IOException see specific implementation
*/
-  public abstract FileStatus[] listStatus(Path f) throws 
FileNotFoundException, 
- IOException;
+  public abstract FileStatus[] listStatus(Path f) throws IOException;
 
   /**
* Represents a batch of directory entries when iteratively listing a
@@ -1600,10 +1601,7 @@ public abstract class FileSystem extends Configured 
implements Closeable {
   private void listStatus(ArrayList results, Path f,
   PathFilter filter) throws FileNotFoundException, IOException {
 FileStatus listing[] = listStatus(f);
-if (listing == null) {
-  throw new IOException("Error accessing " + f);
-}
-
+Preconditions.checkNotNull(listing, "listStatus should not return NULL");
 for (int i = 0; i < listing.length; i++) {
   if (filter.accept(listing[i].getPath())) {
 results.add(listing[i]);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efdf810c/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
--
diff --git 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
index 0fcddcf..5e6cb05 100644
--- 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
+++ 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java
@@ -466,10 +466,7 @@ public class RawLocalFileSystem extends FileSystem {
 }
 
 if (localf.isDirectory()) {
-  String[] names = localf.list();
-  if (names == null) {
-return null;
-  }
+  String[] names = FileUtil.list(localf);
   results = new FileStatus[names.length];
   int j = 0;
   for (int i = 0; i < names.length; i++) {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efdf810c/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
--
diff --git 
a/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
 
b/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
index d927b8b..063bd97 100644
---