You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "pgrandjean (via GitHub)" <gi...@apache.org> on 2023/05/17 00:25:21 UTC

[GitHub] [hadoop] pgrandjean commented on a diff in pull request #5653: HADOOP-18652. Path.suffix raises NullPointerException

pgrandjean commented on code in PR #5653:
URL: https://github.com/apache/hadoop/pull/5653#discussion_r1195804985


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java:
##########
@@ -465,6 +465,10 @@ private Path getParentUtil() {
    * @return a new path with the suffix added
    */
   public Path suffix(String suffix) {
+    if (getParent() == null) {
+      return new Path("/", getName()+suffix);

Review Comment:
   fixed



##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestPath.java:
##########
@@ -528,4 +528,11 @@ public void testSerDeser() throws Throwable {
     }
 
   }
+
+  @Test(timeout = 30000)
+  public void testSuffixFromRoot() {
+    Path root = new Path("/");
+    Assert.assertNull(root.getParent());
+    Assert.assertEquals(root.suffix("bar"), new Path("/bar"));

Review Comment:
   fixed



-- 
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: common-issues-unsubscribe@hadoop.apache.org

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


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