Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ywangd committed Sep 8, 2023
1 parent 50fc99f commit 22341aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CacheIteratorHelper(Cache<K, V> cache) {
iteratorLock = new ReleasableLock(lock.writeLock());
}

public ReleasableLock acquireForUpdate() {
public ReleasableLock acquireUpdateLock() {
return updateLock.acquire();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void processValidatedJwt(
() -> format("Realm [%s] roles resolved [%s] for principal=[%s].", name(), join(",", user.roles()), principal)
);
if (isCacheEnabled()) {
try (ReleasableLock ignored = jwtCacheHelper.acquireForUpdate()) {
try (ReleasableLock ignored = jwtCacheHelper.acquireUpdateLock()) {
final long expWallClockMillis = claimsSet.getExpirationTime().getTime() + allowedClockSkew.getMillis();
jwtCache.put(jwtCacheKey, new ExpiringUser(result.getValue(), new Date(expWallClockMillis)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private void buildThenMaybeCacheRole(
restrictedIndices,
listener.delegateFailureAndWrap((delegate, role) -> {
if (role != null && tryCache) {
try (ReleasableLock ignored = roleCacheHelper.acquireForUpdate()) {
try (ReleasableLock ignored = roleCacheHelper.acquireUpdateLock()) {
/* this is kinda spooky. We use a read/write lock to ensure we don't modify the cache if we hold
* the write lock (fetching stats for instance - which is kinda overkill?) but since we fetching
* stuff in an async fashion we need to make sure that if the cache got invalidated since we
Expand Down Expand Up @@ -546,7 +546,7 @@ public static void buildRoleFromDescriptors(
public void invalidateAll() {
numInvalidation.incrementAndGet();
negativeLookupCache.invalidateAll();
try (ReleasableLock ignored = roleCacheHelper.acquireForUpdate()) {
try (ReleasableLock ignored = roleCacheHelper.acquireUpdateLock()) {
roleCache.invalidateAll();
}
dlsBitsetCache.clear("role store invalidation");
Expand Down

0 comments on commit 22341aa

Please sign in to comment.