Skip to content

HDDS-16835. Remove unreachable endsWith branch in S3 ListObjects - #11467

Open
iprithv wants to merge 3 commits into
apache:masterfrom
iprithv:HDDS-16835
Open

iprithv wants to merge 3 commits into
apache:masterfrom
iprithv:HDDS-16835

Conversation

@iprithv

@iprithv iprithv commented Oct 10, 2026 •

Copy link
Copy Markdown

else if (relativeKeyName.endsWith(delimiter)) can never run. It is only reached when relativeKeyName does not contain the delimiter, so it cannot end with it either.

The case it was meant for (prefix dir, key dir/) is already handled by the indexOf(delimiter) branch, which adds the common prefix dir/.

removed the unreachable branch and added a regression test for that case.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16835

patch tested:
mvn -pl :ozone-s3gateway -am test -Dtest=TestBucketList -DskipShade -DskipRecon -DskipDocs

Result: Tests run: 33, Failures: 0, Errors: 0, Skipped: 0

Fork CI (build-branch on HDDS-16835, commit 77837c13c2): success
https://github.com/iprithv/ozone/actions/runs/38065079180

Signed-off-by: prithvi <prithvisivasankar@gmail.com>

@F64116045 F64116045 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @iprithv , the change overall looks good!

But the PR title should use a period instead of a colon( HDDS-16835. Remove unreachable endsWith branch in S3 ListObjects), otherwise the title check in CI will fail.

Also, CI has not run in your fork. I think you need to enable GitHub Actions in your fork and push again.

It would also be good to follow the PR template in the description

@github-actions github-actions Bot added the s3 S3 Gateway label Oct 10, 2026
@iprithv iprithv changed the title HDDS-16835: Remove unreachable endsWith branch in S3 ListObjects HDDS-16835. Remove unreachable endsWith branch in S3 ListObjects Oct 10, 2026
*/
@Test
public void listExactPrefixWithTrailingDelimiter() throws OS3Exception, IOException {
setup("dir/", "dir/file1", "other");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this test does not really check the dir/ key.
dir/file1 alone already gives the common prefix dir/, so the
test passes even if dir/ is removed from setup.

Maybe use setup("dir/", "other") instead?

Signed-off-by: prithvi <prithvisivasankar@gmail.com>
@iprithv

iprithv commented Oct 10, 2026

Copy link
Copy Markdown
Author

thanks for the quick review! updatd the title, description and test, and enabled actions on the fork..

@Russole Russole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @iprithv for the PR! Could you please also add the test results from your fork to the PR description?

@iprithv

iprithv commented Oct 10, 2026

Copy link
Copy Markdown
Author

sure, done @Russole. thanks for checking this!

@iprithv
iprithv requested review from F64116045 and Russole October 10, 2026 20:29

/**
* Key equal to prefix + delimiter (dir/ with prefix dir) is handled by the
* indexOf(delimiter) branch as a common prefix. An endsWith(delimiter)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more small thing I just noticed
after this PR is merged, there is no endsWith in the code anymore, so the second sentence may confuse future readers.

@F64116045 F64116045 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. LGTM.
Left one minor comment, feel free to take it

Signed-off-by: prithvi <prithvisivasankar@gmail.com>
@iprithv
iprithv requested a review from F64116045 October 11, 2026 09:47

@Russole Russole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @iprithv for the PR. LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants