Fix high load performance issue in token expiration task
parent
ffc5782810
commit
099211593c
|
@ -61,8 +61,28 @@ public interface OAuth2TokenRepository {
|
||||||
|
|
||||||
public Set<OAuth2AccessTokenEntity> getAccessTokensForResourceSet(ResourceSet rs);
|
public Set<OAuth2AccessTokenEntity> getAccessTokensForResourceSet(ResourceSet rs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes duplicate access tokens.
|
||||||
|
*
|
||||||
|
* @deprecated this method was added to return the remove duplicate access tokens values
|
||||||
|
* so that {code removeAccessToken(OAuth2AccessTokenEntity o)} would not to fail. the
|
||||||
|
* removeAccessToken method has been updated so as it will not fail in the event that an
|
||||||
|
* accessToken has been duplicated, so this method is unnecessary.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void clearDuplicateAccessTokens();
|
public void clearDuplicateAccessTokens();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes duplicate refresh tokens.
|
||||||
|
*
|
||||||
|
* @deprecated this method was added to return the remove duplicate refresh token value
|
||||||
|
* so that {code removeRefreshToken(OAuth2RefreshTokenEntity o)} would not to fail. the
|
||||||
|
* removeRefreshToken method has been updated so as it will not fail in the event that
|
||||||
|
* refreshToken has been duplicated, so this method is unnecessary.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void clearDuplicateRefreshTokens();
|
public void clearDuplicateRefreshTokens();
|
||||||
|
|
||||||
public List<OAuth2AccessTokenEntity> getAccessTokensForApprovedSite(ApprovedSite approvedSite);
|
public List<OAuth2AccessTokenEntity> getAccessTokensForApprovedSite(ApprovedSite approvedSite);
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(value="defaultTransactionManager")
|
@Transactional(value="defaultTransactionManager")
|
||||||
public void removeAccessToken(OAuth2AccessTokenEntity accessToken) {
|
public void removeAccessToken(OAuth2AccessTokenEntity accessToken) {
|
||||||
OAuth2AccessTokenEntity found = getAccessTokenByValue(accessToken.getValue());
|
OAuth2AccessTokenEntity found = getAccessTokenById(accessToken.getId());
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
manager.remove(found);
|
manager.remove(found);
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,7 +140,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(value="defaultTransactionManager")
|
@Transactional(value="defaultTransactionManager")
|
||||||
public void removeRefreshToken(OAuth2RefreshTokenEntity refreshToken) {
|
public void removeRefreshToken(OAuth2RefreshTokenEntity refreshToken) {
|
||||||
OAuth2RefreshTokenEntity found = getRefreshTokenByValue(refreshToken.getValue());
|
OAuth2RefreshTokenEntity found = getRefreshTokenById(refreshToken.getId());
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
manager.remove(found);
|
manager.remove(found);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -489,10 +489,6 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
|
||||||
@Override
|
@Override
|
||||||
public void clearExpiredTokens() {
|
public void clearExpiredTokens() {
|
||||||
logger.debug("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<OAuth2AccessTokenEntity> accessTokens = getExpiredAccessTokens();
|
Collection<OAuth2AccessTokenEntity> accessTokens = getExpiredAccessTokens();
|
||||||
if (accessTokens.size() > 0) {
|
if (accessTokens.size() > 0) {
|
||||||
|
|
Loading…
Reference in New Issue