chia7712 commented on code in PR #17026:
URL: https://github.com/apache/kafka/pull/17026#discussion_r1777963227


##########
core/src/main/scala/kafka/server/DelegationTokenManagerZk.scala:
##########
@@ -178,8 +178,10 @@ class DelegationTokenManagerZk(config: KafkaConfig,
 
         val issueTimeStamp = time.milliseconds
         val maxLifeTime = if (maxLifeTimeMs <= 0) tokenMaxLifetime else 
Math.min(maxLifeTimeMs, tokenMaxLifetime)
-        val maxLifeTimeStamp = issueTimeStamp + maxLifeTime
-        val expiryTimeStamp = Math.min(maxLifeTimeStamp, issueTimeStamp + 
defaultTokenRenewTime)
+
+        val isOverflowed = checkTimestampOverflow(issueTimeStamp, maxLifeTime)

Review Comment:
   This is too complicated. Could you please add `sum` method?
   ```java
       private static long sum(long now, long duration) {
           return Long.MAX_VALUE - now <= duration ? Long.MAX_VALUE : now + 
duration;
       }
   ```
   
   ```java
           long maxTimestamp = sum(now, maxLifeTime);
           long expiryTimestamp = Math.min(maxTimestamp, sum(now, 
tokenDefaultRenewLifetimeMs));
   
   ```
   



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to