[ 
https://issues.apache.org/jira/browse/HIVE-30199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Shohei Okumiya resolved HIVE-30199.
-----------------------------------
    Fix Version/s: 4.3.0
       Resolution: Fixed

> Fix inverted Duration.between in TokenIntrospectionAuthenticator cache expiry
> -----------------------------------------------------------------------------
>
>                 Key: HIVE-30199
>                 URL: https://issues.apache.org/jira/browse/HIVE-30199
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Raghav Aggarwal
>            Assignee: Raghav Aggarwal
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.3.0
>
>
> In {{{}TokenIntrospectionAuthenticator{}}},the calculation for the token 
> lifespan in {{expireAfterCreate}} and {{expireAfterUpdate}} has its 
> parameters inverted: 
> {code:java}
> final var expiresIn = Duration.between(value.getExpirationTime().toInstant(), 
> clock.instant());
> return Math.min(expiresIn.toNanos(), maxExpiration.toNanos());{code}
>   Because java.time.Duration.between(start, end) evaluates to end - start:
>   • It computes clock.instant() - expirationTime which evaluated to a 
> negative duration
>   • Per Caffeine's Expiry contract, any duration ≤ 0 instructs the cache to 
> expire and evict the entry immediately.
>  This means the cache would lead to 100% miss rate



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to