Skip to content

Commit c3ffd05

Browse files
authored
HDDS-15178. Allow creating EncodingTypeObject for empty String (#10195)
1 parent 0be20f1 commit c3ffd05

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/commontypes/EncodingTypeObject.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.hadoop.ozone.s3.commontypes;
1919

2020
import jakarta.annotation.Nullable;
21-
import org.apache.commons.lang3.StringUtils;
2221

2322
/**
2423
* A converter to encode string if needed.
@@ -41,12 +40,12 @@ public String getName() {
4140
}
4241

4342
/**
44-
* Create a EncodingTypeObject Object, if the parameter name is null.
43+
* Create a EncodingTypeObject Object, if the parameter name is not null.
4544
* @return If name is null return null else return a EncodingTypeObject object
4645
*/
4746
@Nullable public static EncodingTypeObject createNullable(
4847
@Nullable String name, @Nullable String encodingType) {
49-
if (StringUtils.isEmpty(name)) {
48+
if (name == null) {
5049
return null;
5150
}
5251
return new EncodingTypeObject(name, encodingType);

hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/commontypes/TestObjectKeyNameAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public void testEncodeResult() throws Exception {
4242
.marshal(EncodingTypeObject.createNullable("a b c/", null)));
4343
assertEquals("a+b+c/", getAdapter()
4444
.marshal(EncodingTypeObject.createNullable("a+b+c/", null)));
45+
46+
assertEquals("", getAdapter()
47+
.marshal(EncodingTypeObject.createNullable("", null)));
48+
assertEquals("", getAdapter()
49+
.marshal(EncodingTypeObject.createNullable("", ENCODING_TYPE)));
4550
}
4651

4752
private XmlAdapter<String, EncodingTypeObject> getAdapter() {

hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketList.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public void listRoot() throws OS3Exception, IOException {
5858
endpoint.queryParamsForTest().set(QueryParams.PREFIX, "");
5959
ListObjectResponse getBucketResponse = (ListObjectResponse) endpoint.get("b1").getEntity();
6060

61+
assertNotNull(getBucketResponse.getPrefix());
62+
assertEquals("", getBucketResponse.getPrefix().getName());
63+
6164
assertEquals(1, getBucketResponse.getCommonPrefixes().size());
6265
assertEquals("dir1/",
6366
getBucketResponse.getCommonPrefixes().get(0).getPrefix().getName());

0 commit comments

Comments
 (0)