arunk-kumar opened a new pull request, #8590:
URL: https://github.com/apache/hadoop/pull/8590

   ### Description of PR
   
   When `java.net.URI` reinterprets a stray `//` in a `Path` as the authority 
delimiter (see HADOOP-8087), the intended host or bucket may be silently 
dropped. `FileSystem.checkPath` then throws `IllegalArgumentException` with a 
"Wrong FS" message that no longer contains the caller's input, which makes the 
cause hard to diagnose.
   
   For example, `new Path("hdfs:////some/file")` parses to a URI with a null 
authority, and the current message reads `Wrong FS: hdfs:/some/file, expected: 
hdfs://cluster/` with no clue that a leading double slash was the cause.
   
   This PR appends a short diagnostic hint to the exception message when three 
conditions all hold: the path URI has a scheme, the path URI's authority is 
null, and this FileSystem has a non-null authority. The primary `Wrong FS: 
<path>, expected: <fs-uri>` text is preserved, so existing callers and log 
parsers keep working. Users hitting the common `scheme:////file` typo now see a 
message that names the cause and references HADOOP-8087.
   
   The hint is deliberately narrow. Joining a Path with a child that begins 
with `//`, e.g. `new Path(new Path("s3://bucket/"), "//file")`, promotes the 
child's first segment to the authority position with a non-null value; that 
shape is not distinguishable at check time from a plain wrong-host root path 
(`hdfs://wronghost/`) without false positives. A follow-up in `Path`'s 
constructors would be the right place to catch that shape, since the original 
input string is only available there.
   
   ### How was this patch tested?
   
   Added a new unit test `testWrongFsHintOnMissingAuthority` in 
`TestFileSystemCanonicalization` covering the null-authority case. The existing 
exact-match assertion on the "Wrong FS" message in the same file is relaxed 
from `assertEquals(...)` to `assertTrue(msg.startsWith(...))` so the primary 
contract is preserved without over-specifying wording. `mvn -pl 
hadoop-common-project/hadoop-common test -Dtest=TestFileSystemCanonicalization` 
passes 17/17 (16 existing + 1 new). Locally validated the message end-to-end 
with a stub FileSystem driver against the null-authority case, the child-`//` 
displacement case, and a plain scheme/host mismatch — the hint fires only for 
the null-authority case.
   
   ### For code changes:
   
   - [x] Does the title or this PR starts with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: have the integration tests been executed and the 
endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   ### AI Tooling
   
   Contains content generated by Claude.


-- 
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]

Reply via email to