You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "sadanand48 (via GitHub)" <gi...@apache.org> on 2023/09/03 08:31:51 UTC

[GitHub] [ozone] sadanand48 commented on a diff in pull request #5239: HDDS-4838. Deleting at bucket root throws NPE.

sadanand48 commented on code in PR #5239:
URL: https://github.com/apache/ozone/pull/5239#discussion_r1314176835


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
     Assert.assertTrue(o3fs.exists(userTrashCurrent));
     // Check under trash, the key should be present
     Assert.assertTrue(o3fs.exists(trashPath));
+
+    // Try to delete root
+    Path root = new Path(OZONE_URI_DELIMITER);
+    try {
+      trash.moveToTrash(root);
+      Assert.fail("Trying to delete root should throw exception");
+    } catch (Exception e) {
+      Assert.assertTrue(e instanceof IOException);
+    }
+    // Also try with TrashPolicyDefault
+    OzoneConfiguration conf2 = new OzoneConfiguration(cluster.getConf());
+    conf2.setClass("fs.trash.classname", TrashPolicyDefault.class,
+        TrashPolicy.class);
+    Trash trashPolicyDefault = new Trash(conf2);
+    try {
+      trashPolicyDefault.moveToTrash(root);
+      Assert.fail("Trying to delete root should throw exception");
+    } catch (Exception e) {
+      Assert.assertTrue(e instanceof IOException);
+    }

Review Comment:
   Done.



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
     Assert.assertTrue(o3fs.exists(userTrashCurrent));
     // Check under trash, the key should be present
     Assert.assertTrue(o3fs.exists(trashPath));
+
+    // Try to delete root
+    Path root = new Path(OZONE_URI_DELIMITER);
+    try {
+      trash.moveToTrash(root);
+      Assert.fail("Trying to delete root should throw exception");
+    } catch (Exception e) {
+      Assert.assertTrue(e instanceof IOException);
+    }

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org