deepujain opened a new pull request, #8307:
URL: https://github.com/apache/hadoop/pull/8307
### Summary
Documents how Path handles trailing slashes and how that affects
`URI.resolve()`. The String constructor (and other constructors that use string
path components) normalize the path and remove trailing slashes; the URI
constructor preserves the provided URI after `URI.normalize()`, including any
trailing slash. This clarifies why `new
Path("hdfs://host/dir/").toUri().resolve("x")` yields `hdfs://host/x` while
`new Path(new URI("hdfs://host/dir/")).toUri().resolve("x")` yields
`hdfs://host/dir/x`, and guides users to use the URI constructor or path
concatenation when resolution behavior matters.
### Change
- **Path.java**
- Class-level javadoc: added "Trailing slash and URI resolution" paragraph
describing the difference between `Path(URI)` (preserves trailing slash) and
`Path(String)` (strips it), and the impact on `toUri().resolve()`.
- `Path(String)`: noted that trailing slashes are removed and that
`Path(URI)` should be used when resolution behavior must preserve a trailing
slash.
- `Path(URI)`: noted that the URI is preserved including trailing slash so
that `path.toUri().resolve(relative)` works correctly for directory paths.
### JIRA
Fixes HADOOP-19815
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]