ChenSammi commented on code in PR #11290:
URL: https://github.com/apache/ozone/pull/11290#discussion_r4078830353
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3LifecycleConfiguration.java:
##########
@@ -168,14 +170,30 @@ public void setDate(String date) {
@XmlRootElement(name = "AbortIncompleteMultipartUpload")
public static class AbortIncompleteMultipartUpload {
@XmlElement(name = "DaysAfterInitiation")
- private Integer daysAfterInitiation;
+ private String daysAfterInitiation;
public Integer getDaysAfterInitiation() {
- return daysAfterInitiation;
+ return parseDays(daysAfterInitiation);
}
public void setDaysAfterInitiation(Integer daysAfterInitiation) {
- this.daysAfterInitiation = daysAfterInitiation;
+ this.daysAfterInitiation = daysAfterInitiation == null ? null :
daysAfterInitiation.toString();
+ }
+ }
+
+ /**
+ * Parses a lifecycle day-count element, rejecting a value that does not fit
in an int instead
+ * of silently overflowing it the way JAXB's built-in Integer converter
would.
+ */
+ private static Integer parseDays(String value) {
+ if (value == null) {
+ return null;
+ }
+ try {
+ return Integer.parseInt(value.trim());
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Invalid lifecycle configuration:
Days value '" + value
Review Comment:
Let's show the consistent error message here,
`'Days' for Expiration action must be a positive integer greater than zero.`
--
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]