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

Raghav Aggarwal updated HIVE-30199:
-----------------------------------
    Description: 
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

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