Skip to content

Commit

Permalink
LoginResult#tokenTtl is non-nullable. Make it primitive type.
Browse files Browse the repository at this point in the history
In Expiry implementation, must be converted from ttl(in seconds) to nano seconds.
  • Loading branch information
KonaEspresso94 committed Jul 21, 2024
1 parent 1d3f9c6 commit c773424
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,24 @@ static Function<? super HttpClient, LoginClient> newDecorator(WebClient webClien
@Override
public long expireAfterCreate(String key, LoginResult loginResult,
long currentTime) {
return loginResult.tokenTtl.longValue();
return ttlToNanoSeconds(loginResult.tokenTtl);
}

@Override
public long expireAfterUpdate(String key, LoginResult loginResult,
long currentTime, long currentDuration) {
return loginResult.tokenTtl.longValue();
return ttlToNanoSeconds(loginResult.tokenTtl);
}

@Override
public long expireAfterRead(String key, LoginResult loginResult,
long currentTime, long currentDuration) {
return currentDuration;
}

private long ttlToNanoSeconds(int ttlInSeconds) {
return ttlInSeconds * 1_000_000_000L;
}
})
.buildAsync((key, executor) -> {
try {
Expand Down Expand Up @@ -134,7 +138,7 @@ public HttpResponse execute(ClientRequestContext ctx, HttpRequest req) {
private static final class LoginResult {
private final String accessToken;

private final Integer tokenTtl;
private final int tokenTtl;

@Nullable
private final Boolean globalAdmin;
Expand Down

0 comments on commit c773424

Please sign in to comment.