You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ad...@apache.org on 2026/05/19 11:42:55 UTC
(ozone) branch master updated: HDDS-15303. Apply prefix filter to listing OBS bucket (#10298)
This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new c0781aa9ec6 HDDS-15303. Apply prefix filter to listing OBS bucket (#10298)
c0781aa9ec6 is described below
commit c0781aa9ec66d59bc1bbb4cf2ef6bb69ce2a596c
Author: Peter Lee <pe...@gmail.com>
AuthorDate: Tue May 19 19:42:49 2026 +0800
HDDS-15303. Apply prefix filter to listing OBS bucket (#10298)
---
.../apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java | 6 +-----
.../apache/hadoop/ozone/s3/endpoint/TestBucketList.java | 14 ++++++++++++++
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
index 2fd6dee16db..83965732db2 100644
--- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
+++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
@@ -180,11 +180,7 @@ Response handleGetRequest(S3RequestContext context, String bucketName) throws IO
if (maxKeys > 0) {
while (ozoneKeyIterator != null && ozoneKeyIterator.hasNext()) {
OzoneKey next = ozoneKeyIterator.next();
- if (bucket != null && bucket.getBucketLayout().isFileSystemOptimized() &&
- StringUtils.isNotEmpty(prefix) &&
- !next.getName().startsWith(prefix)) {
- // prefix has delimiter but key don't have
- // example prefix: dir1/ key: dir123
+ if (StringUtils.isNotEmpty(prefix) && !next.getName().startsWith(prefix)) {
continue;
}
if (startAfter != null && count == 0 && Objects.equals(startAfter, next.getName())) {
diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketList.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketList.java
index a703cdeaae3..d2a47c0c586 100644
--- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketList.java
+++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketList.java
@@ -136,6 +136,20 @@ public void listObjectOwner() throws OS3Exception, IOException {
getBucketResponse.getContents().get(1).getOwner().getDisplayName());
}
+ @Test
+ public void listWithDelimiterAndPrefixMatchingNoKeys() throws OS3Exception, IOException {
+ OzoneClient ozoneClient =
+ createClientWithKeys("b/a/r", "b/a/c", "b/a/g", "g");
+ BucketEndpoint endpoint = newBucketEndpointBuilder().setClient(ozoneClient).build();
+
+ endpoint.queryParamsForTest().set(QueryParams.DELIMITER, "d");
+ endpoint.queryParamsForTest().set(QueryParams.PREFIX, "/");
+ ListObjectResponse response = (ListObjectResponse) endpoint.get("b1").getEntity();
+
+ assertEquals(0, response.getContents().size());
+ assertEquals(0, response.getCommonPrefixes().size());
+ }
+
@Test
public void listWithPrefixAndDelimiter() throws OS3Exception, IOException {
OzoneClient ozoneClient =
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org