priyeshkaratha commented on code in PR #12170:
URL: https://github.com/apache/ozone/pull/12170#discussion_r4811134386


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCExpiration.java:
##########
@@ -67,15 +66,43 @@ public String getDate() {
     return date;
   }
 
+  /**
+   * Whether an object last modified at the given time has expired under this 
action, that is, the current time is
+   * after {@link #getExpiryTime(long)}.
+   *
+   * @param timestamp modification time of the object in milliseconds since 
epoch
+   */
   public boolean isExpired(long timestamp) {
-    ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
+    Instant expiryTime = getExpiryTime(timestamp);
+    return expiryTime != null && Instant.now().isAfter(expiryTime);
+  }
+
+  /**
+   * Returns when an object last modified at the given time expires under this 
action, as AWS S3 computes it for both
+   * the x-amz-expiration header and the actual expiration: for Days, the 
modification time plus the days, rounded up
+   * to the next midnight UTC; for Date, the configured date.
+   *
+   * @param modificationTime modification time of the object in milliseconds 
since epoch
+   * @return the expiry time, or null if neither a positive Days nor a 
parsable Date is set
+   */
+  @Nullable
+  public Instant getExpiryTime(long modificationTime) {
+    if (days != null && days > 0) {

Review Comment:
   Good catch, thanks. Yes, Days=0 should still expire right away in test mode. 
getExpiryTime now returns the modification time itself for Days=0



-- 
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