quieted logging on database cleanup tasks when no expired elements are found

pull/988/head
Justin Richer 9 years ago
parent fcfc620d51
commit 1ed3e2c47a

@ -121,8 +121,9 @@ public class DefaultOAuth2AuthorizationCodeService implements AuthorizationCodeS
repository.remove(code); repository.remove(code);
} }
logger.info("Removed " + codes.size() + " expired authorization codes."); if (codes.size() > 0) {
logger.info("Removed " + codes.size() + " expired authorization codes.");
}
} }
/** /**

@ -423,14 +423,16 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
*/ */
@Override @Override
public void clearExpiredTokens() { 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 // get all the duplicated tokens first to maintain consistency
tokenRepository.clearDuplicateAccessTokens(); tokenRepository.clearDuplicateAccessTokens();
tokenRepository.clearDuplicateRefreshTokens(); tokenRepository.clearDuplicateRefreshTokens();
Collection<OAuth2AccessTokenEntity> accessTokens = getExpiredAccessTokens(); Collection<OAuth2AccessTokenEntity> 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) { for (OAuth2AccessTokenEntity oAuth2AccessTokenEntity : accessTokens) {
try { try {
revokeAccessToken(oAuth2AccessTokenEntity); revokeAccessToken(oAuth2AccessTokenEntity);
@ -442,13 +444,17 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
} }
Collection<OAuth2RefreshTokenEntity> refreshTokens = getExpiredRefreshTokens(); Collection<OAuth2RefreshTokenEntity> 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) { for (OAuth2RefreshTokenEntity oAuth2RefreshTokenEntity : refreshTokens) {
revokeRefreshToken(oAuth2RefreshTokenEntity); revokeRefreshToken(oAuth2RefreshTokenEntity);
} }
Collection<AuthenticationHolderEntity> authHolders = getOrphanedAuthenticationHolders(); Collection<AuthenticationHolderEntity> 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) { for(AuthenticationHolderEntity authHolder : authHolders) {
authenticationHolderRepository.remove(authHolder); authenticationHolderRepository.remove(authHolder);
} }

@ -158,7 +158,9 @@ public class DefaultApprovedSiteService implements ApprovedSiteService {
logger.info("Clearing expired approved sites"); logger.info("Clearing expired approved sites");
Collection<ApprovedSite> expiredSites = getExpired(); Collection<ApprovedSite> 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) { if (expiredSites != null) {
for (ApprovedSite expired : expiredSites) { for (ApprovedSite expired : expiredSites) {
remove(expired); remove(expired);

Loading…
Cancel
Save