This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 93ae1cfcd5 HDDS-7132. GetFileStatus returns NULL for some paths. 
(#3687)
93ae1cfcd5 is described below

commit 93ae1cfcd57fc05d2356b44baad0bdef53b7c149
Author: Ayush Saxena <[email protected]>
AuthorDate: Thu Aug 25 18:09:56 2022 +0530

    HDDS-7132. GetFileStatus returns NULL for some paths. (#3687)
---
 .../hadoop/fs/ozone/TestRootedOzoneFileSystem.java    | 12 ++++++++++++
 .../apache/hadoop/fs/ozone/BasicOzoneFileSystem.java  | 11 ++++++++---
 .../hadoop/fs/ozone/BasicRootedOzoneFileSystem.java   | 19 ++++++++++---------
 3 files changed, 30 insertions(+), 12 deletions(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
index 9ff481b4b4..da86169282 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
@@ -1723,6 +1723,18 @@ public class TestRootedOzoneFileSystem {
         key.getReplicationConfig().getReplicationType().name());
   }
 
+  @Test
+  public void testGetFileStatus() throws Exception {
+    String volumeNameLocal = getRandomNonExistVolumeName();
+    String bucketNameLocal = RandomStringUtils.randomNumeric(5);
+    Path volume = new Path("/" + volumeNameLocal);
+    ofs.mkdirs(volume);
+    LambdaTestUtils.intercept(OMException.class,
+        () -> ofs.getFileStatus(new Path(volume, bucketNameLocal)));
+    // Cleanup
+    ofs.delete(volume, true);
+  }
+
   @Test
   public void testUnbuffer() throws IOException {
     String testKeyName = "testKey2";
diff --git 
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
 
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
index 910ca45584..2e756a5e6a 100644
--- 
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
+++ 
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
@@ -755,10 +755,15 @@ public class BasicOzoneFileSystem extends FileSystem {
     try {
       fileStatus = convertFileStatus(
           adapter.getFileStatus(key, uri, qualifiedPath, getUsername()));
-    } catch (OMException ex) {
-      if (ex.getResult().equals(OMException.ResultCodes.KEY_NOT_FOUND)) {
-        throw new FileNotFoundException("File not found. path:" + f);
+    } catch (IOException ex) {
+      if (ex instanceof OMException) {
+        if (((OMException) ex).getResult()
+            .equals(OMException.ResultCodes.KEY_NOT_FOUND)) {
+          throw new FileNotFoundException("File not found. path:" + f);
+        }
       }
+      LOG.warn("GetFileStatus failed for path {}", f, ex);
+      throw ex;
     }
     return fileStatus;
   }
diff --git 
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
 
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
index b1f019374a..fbd800f203 100644
--- 
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
+++ 
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
@@ -577,10 +577,6 @@ public class BasicRootedOzoneFileSystem extends FileSystem 
{
       return false;
     }
 
-    if (status == null) {
-      return false;
-    }
-
     String key = pathToKey(f);
     boolean result;
 
@@ -871,12 +867,17 @@ public class BasicRootedOzoneFileSystem extends 
FileSystem {
     try {
       fileStatus = convertFileStatus(
           adapter.getFileStatus(key, uri, qualifiedPath, getUsername()));
-    } catch (OMException ex) {
-      if (ex.getResult().equals(OMException.ResultCodes.KEY_NOT_FOUND) ||
-          ex.getResult().equals(OMException.ResultCodes.BUCKET_NOT_FOUND) ||
-          ex.getResult().equals(OMException.ResultCodes.VOLUME_NOT_FOUND)) {
-        throw new FileNotFoundException("File not found. path:" + f);
+    } catch (IOException e) {
+      if (e instanceof OMException) {
+        OMException ex = (OMException) e;
+        if (ex.getResult().equals(OMException.ResultCodes.KEY_NOT_FOUND) ||
+            ex.getResult().equals(OMException.ResultCodes.BUCKET_NOT_FOUND) ||
+            ex.getResult().equals(OMException.ResultCodes.VOLUME_NOT_FOUND)) {
+          throw new FileNotFoundException("File not found. path:" + f);
+        }
       }
+      LOG.warn("GetFileStatus failed for path {}", f, e);
+      throw e;
     }
     return fileStatus;
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to