[#8010] improvement: fix resource path enumeration to accumulate parent segments #9371
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 changes were proposed in this pull request?
This PR fixes the incorrect resource path enumeration logic in the GCS token provider by ensuring that multi-level paths accumulate parent segments correctly and include both non-directory and directory variants where appropriate.
Additionally, the logic that previously concatenated strings to the
parentvariable using + operations has been replaced with a StringBuilder for improved efficiency, and cases whereresourcePathis null are now handled safely.Why are the changes needed?
The previous implementation did not include the non-directory path segments for intermediate levels.
Additionally, repeatedly concatenating strings using the + operator introduced unnecessary overhead, and the absence of null handling for resourcePath could result in unexpected exceptions.
Fix: #8010
Does this PR introduce any user-facing change?
No new user-facing API is introduced.
How was this patch tested?
Use the test code below