Skip to content

Commit 585e04c

Browse files
committed
Fix potential issue with toggling setting mid-permission check (2)
1 parent db83c46 commit 585e04c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

cloud-core/src/main/java/org/incendo/cloud/CommandManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,11 @@ public boolean hasCapability(final @NonNull CloudCapability capability) {
413413
final boolean cache = this.settings.get(ManagerSetting.REDUCE_REDUNDANT_PERMISSION_CHECKS);
414414
try {
415415
if (cache) {
416-
this.threadLocalPermissionCache.get().second().incrementAndGet();
416+
final int prev = this.threadLocalPermissionCache.get().second().incrementAndGet();
417+
if (prev == 0) {
418+
// Cleanup from case where cache was enabled mid-permission check
419+
this.threadLocalPermissionCache.get().first().clear();
420+
}
417421
}
418422
return this.testPermission_(sender, permission);
419423
} finally {

0 commit comments

Comments
 (0)