[ 
https://issues.apache.org/jira/browse/HADOOP-17744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17356679#comment-17356679
 ] 

Viraj Jasani edited comment on HADOOP-17744 at 6/9/21, 4:09 PM:
----------------------------------------------------------------

Outputs on trunk as of today:

1.
{code:java}
Path path = new Path("file:///something").suffix("else");
System.out.println(path);
{code}
output:
{code:java}
file:/somethingelse{code}
2.
{code:java}
Path path = new Path("/something").suffix("else");
System.out.println(path);
{code}
output:
{code:java}
/somethingelse{code}


was (Author: vjasani):
On trunk, with scheme, suffix is producing NPE:
{code:java}
new Path("file://something").suffix("else")
{code}
output:
{code:java}
java.lang.NullPointerException
 at org.apache.hadoop.fs.Path.<init>(Path.java:152)
 at org.apache.hadoop.fs.Path.<init>(Path.java:130)
 at org.apache.hadoop.fs.Path.suffix(Path.java:468)
{code}
However, this seems to be working fine:
{code:java}
Path path = new Path("/something").suffix("else");
System.out.println(path);
{code}
output:
{code:java}
/somethingelse{code}
 

> Path.suffix() raises an exception when the path is in the root dir
> ------------------------------------------------------------------
>
>                 Key: HADOOP-17744
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17744
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>    Affects Versions: 3.3.1
>            Reporter: Steve Loughran
>            Priority: Minor
>
> Root cause of SPARK-34298.
> If you have a Path (/something) and call suffix on it.
> {code}
>  new Path("/something").suffix("else")
> {code}
> you see an error because the path doesn't have a parent
> {code}
> Exception in thread "main" java.lang.IllegalArgumentException: Can not create 
> a Path from an empty string
> at org.apache.hadoop.fs.Path.checkPathArg(Path.java:168)[....]
> at org.apache.hadoop.fs.Path.suffix(Path.java:446)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to