From 7882c92e5dd1902ecb8c8fa8efaad041bfcbafac Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Wed, 18 Sep 2024 15:04:06 -0500 Subject: [PATCH] ARTEMIS-5049 add detailed logging for auth caches --- .../core/security/impl/SecurityStoreImpl.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java index ed51e17640..ec7b50ca8a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java @@ -120,6 +120,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC .expireAfterWrite(invalidationInterval, TimeUnit.MILLISECONDS) .recordStats() .build(); + logger.trace("Created authn cache: {}; maxSize: {}; invalidationInterval: {}", authenticationCache, authenticationCacheSize, invalidationInterval); } if (authorizationCacheSize == 0) { authorizationCache = null; @@ -129,6 +130,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC .expireAfterWrite(invalidationInterval, TimeUnit.MILLISECONDS) .recordStats() .build(); + logger.trace("Created authz cache: {}; maxSize: {}; invalidationInterval: {}", authorizationCache, authorizationCacheSize, invalidationInterval); } this.securityRepository.registerListener(this); } else { @@ -473,7 +475,9 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC private void putAuthenticationCacheEntry(String key, Subject subject) { if (authenticationCache != null) { - authenticationCache.put(key, new Pair<>(subject != null, subject)); + Pair value = new Pair<>(subject != null, subject); + authenticationCache.put(key, value); + logger.trace("Put into authn cache; key: {}; value: {}", key, value); } } @@ -481,13 +485,16 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC if (authenticationCache == null) { return null; } else { - return authenticationCache.getIfPresent(key); + Pair value = authenticationCache.getIfPresent(key); + logger.trace("Get from authn cache; key: {}; value: {}", key, value); + return value; } } - private void putAuthorizationCacheEntry(ConcurrentHashSet set, String key) { + private void putAuthorizationCacheEntry(ConcurrentHashSet value, String key) { if (authorizationCache != null) { - authorizationCache.put(key, set); + authorizationCache.put(key, value); + logger.trace("Put into authz cache; key: {}; value: {}", key, value); } } @@ -495,19 +502,23 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC if (authorizationCache == null) { return null; } else { - return authorizationCache.getIfPresent(key); + ConcurrentHashSet value = authorizationCache.getIfPresent(key); + logger.trace("Get from authz cache; key: {}; value: {}", key, value); + return value; } } public void invalidateAuthorizationCache() { if (authorizationCache != null) { authorizationCache.invalidateAll(); + logger.trace("Invalidated authz cache"); } } public void invalidateAuthenticationCache() { if (authenticationCache != null) { authenticationCache.invalidateAll(); + logger.trace("Invalidated authn cache"); } }