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 ccab47a1c63 HDDS-15302. Throw S3 InvalidArgument for 
RequestParameters.getInt parse error (#10297)
ccab47a1c63 is described below

commit ccab47a1c6301b7d88be3d94ab6d142831c602e0
Author: Peter Lee <[email protected]>
AuthorDate: Mon May 18 13:54:00 2026 +0800

    HDDS-15302. Throw S3 InvalidArgument for RequestParameters.getInt parse 
error (#10297)
---
 .../hadoop/ozone/s3/commontypes/RequestParameters.java      |  7 +------
 .../org/apache/hadoop/ozone/s3/endpoint/TestBucketList.java | 13 +++++++++++++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git 
a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/commontypes/RequestParameters.java
 
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/commontypes/RequestParameters.java
index 7b5e2d0d6e8..85ff5fae535 100644
--- 
a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/commontypes/RequestParameters.java
+++ 
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/commontypes/RequestParameters.java
@@ -17,7 +17,6 @@
 
 package org.apache.hadoop.ozone.s3.commontypes;
 
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
 import org.apache.hadoop.ozone.s3.exception.S3ErrorTable;
 
@@ -44,14 +43,10 @@ default int getInt(String key, int defaultValue) {
     try {
       return Integer.parseInt(value);
     } catch (NumberFormatException e) {
-      throw translateException(e);
+      throw S3ErrorTable.newError(S3ErrorTable.INVALID_ARGUMENT, key, e);
     }
   }
 
-  default WebApplicationException translateException(RuntimeException e) {
-    return new WebApplicationException(e.getMessage(), 
S3ErrorTable.INVALID_ARGUMENT.getHttpCode());
-  }
-
   /** Additional methods for tests. */
   interface Mutable extends RequestParameters {
 
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 44f1dc5f840..a703cdeaae3 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
@@ -460,6 +460,19 @@ public void testEncodingTypeException() throws IOException 
{
     assertEquals(S3ErrorTable.INVALID_ARGUMENT.getCode(), e.getCode());
   }
 
+  @Test
+  public void testListObjectsWithNonIntegerMaxKeys() throws Exception {
+    OzoneClient client = new OzoneClientStub();
+    client.getObjectStore().createS3Bucket("bucket");
+    BucketEndpoint bucketEndpoint = newBucketEndpointBuilder()
+        .setClient(client)
+        .build();
+
+    bucketEndpoint.queryParamsForTest().set(QueryParams.MAX_KEYS, "blah");
+    OS3Exception e = assertThrows(OS3Exception.class, () -> 
bucketEndpoint.get("bucket"));
+    assertEquals(S3ErrorTable.INVALID_ARGUMENT.getCode(), e.getCode());
+  }
+
   @Test
   public void testListObjectsWithNegativeMaxKeys() throws Exception {
     OzoneClient client = new OzoneClientStub();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to