From 1ed3e2c47a3644d4c16cca64bc23b616df151df1 Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Wed, 25 Nov 2015 15:44:11 -0500 Subject: [PATCH] quieted logging on database cleanup tasks when no expired elements are found --- .../DefaultOAuth2AuthorizationCodeService.java | 5 +++-- .../impl/DefaultOAuth2ProviderTokenService.java | 14 ++++++++++---- .../service/impl/DefaultApprovedSiteService.java | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2AuthorizationCodeService.java b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2AuthorizationCodeService.java index 8403a6f5b..02062090d 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2AuthorizationCodeService.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2AuthorizationCodeService.java @@ -121,8 +121,9 @@ public class DefaultOAuth2AuthorizationCodeService implements AuthorizationCodeS repository.remove(code); } - logger.info("Removed " + codes.size() + " expired authorization codes."); - + if (codes.size() > 0) { + logger.info("Removed " + codes.size() + " expired authorization codes."); + } } /** diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java index f71b44574..a66eff5d8 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java @@ -423,14 +423,16 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi */ @Override public void clearExpiredTokens() { - logger.info("Cleaning out all expired tokens"); + logger.debug("Cleaning out all expired tokens"); // get all the duplicated tokens first to maintain consistency tokenRepository.clearDuplicateAccessTokens(); tokenRepository.clearDuplicateRefreshTokens(); Collection accessTokens = getExpiredAccessTokens(); - logger.info("Found " + accessTokens.size() + " expired access tokens"); + if (accessTokens.size() > 0) { + logger.info("Found " + accessTokens.size() + " expired access tokens"); + } for (OAuth2AccessTokenEntity oAuth2AccessTokenEntity : accessTokens) { try { revokeAccessToken(oAuth2AccessTokenEntity); @@ -442,13 +444,17 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi } Collection refreshTokens = getExpiredRefreshTokens(); - logger.info("Found " + refreshTokens.size() + " expired refresh tokens"); + if (refreshTokens.size() > 0) { + logger.info("Found " + refreshTokens.size() + " expired refresh tokens"); + } for (OAuth2RefreshTokenEntity oAuth2RefreshTokenEntity : refreshTokens) { revokeRefreshToken(oAuth2RefreshTokenEntity); } Collection authHolders = getOrphanedAuthenticationHolders(); - logger.info("Found " + authHolders.size() + " orphaned authentication holders"); + if (authHolders.size() > 0) { + logger.info("Found " + authHolders.size() + " orphaned authentication holders"); + } for(AuthenticationHolderEntity authHolder : authHolders) { authenticationHolderRepository.remove(authHolder); } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultApprovedSiteService.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultApprovedSiteService.java index 15145c05f..d61f7f661 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultApprovedSiteService.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultApprovedSiteService.java @@ -158,7 +158,9 @@ public class DefaultApprovedSiteService implements ApprovedSiteService { logger.info("Clearing expired approved sites"); Collection expiredSites = getExpired(); - logger.info("Found " + expiredSites.size() + " expired approved sites."); + if (expiredSites.size() > 0) { + logger.info("Found " + expiredSites.size() + " expired approved sites."); + } if (expiredSites != null) { for (ApprovedSite expired : expiredSites) { remove(expired);