diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-api/src/main/java/org/xwiki/security/authorization/cache/internal/DefaultSecurityCache.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-api/src/main/java/org/xwiki/security/authorization/cache/internal/DefaultSecurityCache.java index eb00308..e57e10e 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-api/src/main/java/org/xwiki/security/authorization/cache/internal/DefaultSecurityCache.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-api/src/main/java/org/xwiki/security/authorization/cache/internal/DefaultSecurityCache.java @@ -809,14 +809,19 @@ public void cacheEntryAdded( @Override public void cacheEntryRemoved(CacheEntryEvent event) { - if (event.getEntry().getValue().dispose()) { - if (logger.isDebugEnabled()) { - logger.debug("Evicting entry [{}].", event.getEntry().getKey()); - } - } else { - if (logger.isDebugEnabled()) { - logger.debug("Removed entry [{}].", event.getEntry().getKey()); + writeLock.lock(); + try { + if (event.getEntry().getValue().dispose()) { + if (logger.isDebugEnabled()) { + logger.debug("Evicting entry [{}].", event.getEntry().getKey()); + } + } else { + if (logger.isDebugEnabled()) { + logger.debug("Removed entry [{}].", event.getEntry().getKey()); + } } + } finally { + writeLock.unlock(); } }