fmorg-git commented on code in PR #11261:
URL: https://github.com/apache/ozone/pull/11261#discussion_r4067321288


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/S3STSUtils.java:
##########
@@ -101,18 +101,37 @@ public static void addAssumeRoleAuditParams(Map<String, 
String> auditParams, Str
    * @return validated duration
    * @throws OMException if duration is invalid
    */
-  public static int validateDuration(Integer durationSeconds) throws 
OMException {
+  public static int validateDuration(int durationSeconds) throws OMException {
+    if (durationSeconds < MIN_DURATION_SECONDS || durationSeconds > 
MAX_DURATION_SECONDS) {
+      throw new OMException(durationValidationErrorMessage(), INVALID_REQUEST);
+    }
+
+    return durationSeconds;
+  }
+
+  /**
+   * Validates the duration in seconds from a raw request value.
+   * @param durationSeconds duration in seconds as a string
+   * @return validated duration
+   * @throws OMException if duration is invalid
+   */
+  public static int validateDuration(String durationSeconds) throws 
OMException {
     if (durationSeconds == null) {
       return DEFAULT_DURATION_SECONDS;
     }
 
-    if (durationSeconds < MIN_DURATION_SECONDS || durationSeconds > 
MAX_DURATION_SECONDS) {
-      throw new OMException(
-          "Invalid Value: DurationSeconds must be between " + 
MIN_DURATION_SECONDS + " and " + MAX_DURATION_SECONDS +
-          " seconds", INVALID_REQUEST);
+    final int value;
+    try {
+      value = Integer.parseInt(durationSeconds);
+    } catch (NumberFormatException e) {
+      throw new OMException(durationValidationErrorMessage(), INVALID_REQUEST);
     }
+    return validateDuration(value);
+  }
 
-    return durationSeconds;
+  private static String durationValidationErrorMessage() {
+    return "Invalid Value: DurationSeconds must be a number between " + 
MIN_DURATION_SECONDS + " and " +
+        MAX_DURATION_SECONDS + " seconds";

Review Comment:
   updated - 6d734b9c6d4a9415ec56e7d48c1da0d8524fa592



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to