[fix](fs) Make PathUtils.equalsIgnoreSchemeIfOneIsS3 path comparison consistent#64768
Draft
LuciferYang wants to merge 1 commit into
Draft
[fix](fs) Make PathUtils.equalsIgnoreSchemeIfOneIsS3 path comparison consistent#64768LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
…consistent equalsIgnoreSchemeIfOneIsS3 used inconsistent logic across its two branches: same-scheme did a full-string case-INsensitive compare with the trailing slash significant, while cross-scheme (one is s3) compared normalized authority+path case-sensitively with the trailing slash stripped. The result for one URI therefore depended on the other URI's scheme, and same-scheme comparisons wrongly ignored case (S3 keys are case-sensitive). Unify both branches into one rule: when schemes are equal (case-insensitively) or one side is s3, compare the authority and path only, with trailing slashes insignificant and the comparison case-sensitive on the raw (percent-encoded) components; otherwise not equal. This matches the original normalize() intent and the sole caller HMSTransaction (avoid renames when the location is identical). Malformed inputs for object storage (opaque URIs, scheme-with-null-authority triple-slash forms, authority-with-null-scheme network-path references, parse failures) fall back to exact string comparison; percent-encoded slashes stay distinct. Hardened via multi-persona review; adds extensive PathUtilsTest coverage.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: close #64767
Problem Summary:
PathUtils.equalsIgnoreSchemeIfOneIsS3(p1, p2)(used byHMSTransactionto decide whether a Hive commit needs a rename) compared paths inconsistently across its two branches:equalsIgnoreCase(trailing slash significant, case-insensitive);s3→ normalized authority+path viaObjects.equals(trailing slash stripped, case-sensitive).So the result for one URI depended on the other URI's scheme, and same-scheme comparisons wrongly ignored case (S3 keys are case-sensitive).
This PR unifies both branches into one rule: when the schemes are equal (case-insensitively, per RFC 3986 §3.1) or one side is
s3, compare only the authority (bucket/host) and path — scheme ignored, trailing slashes insignificant, case-sensitive on the raw (percent-encoded) components; otherwise the locations are not equal. This matches the originalnormalize()intent and the caller's "no rename when the location is identical" comment, and applies the slash/case handling consistently regardless of whether the two schemes match.Inputs that are malformed for object storage fall back to exact string comparison so they cannot spuriously match: opaque URIs (
s3:bucket/key), scheme-with-null-authority triple-slash forms (s3:///path), authority-with-null-scheme network-path references (//bucket/path), and parse failures. Percent-encoded slashes (%2F) stay distinct from real path separators.The change was hardened via a multi-persona adversarial review loop run to convergence (5 consecutive clean rounds); the extra rounds mainly added test coverage.
Release note
None
Check List (For Author)
Test
PathUtilsTest, 23 cases covering the consistency contract plus opaque/encoded/triple-slash/network-path/null/scheme-family edge cases)Behavior changed:
equalsIgnoreSchemeIfOneIsS3now treats trailing slashes as insignificant and the authority+path comparison as case-sensitive consistently for same-scheme and cross-scheme inputs. For realistic fully-qualified Hive S3/OSS locations the rename decision is unchanged; the difference only appears for trailing-slash-only or case-only differences and for malformed inputs.Does this need documentation?