KEYCLOAK-5617 Intermittent ConcurrencyTest failures
This commit is contained in:
parent
9243430b75
commit
bf937452c6
1 changed files with 4 additions and 6 deletions
|
@ -92,7 +92,7 @@ public class TokenManager {
|
|||
return currentToken;
|
||||
}
|
||||
|
||||
public AccessTokenResponse refreshToken() {
|
||||
public synchronized AccessTokenResponse refreshToken() {
|
||||
Form form = new Form().param(GRANT_TYPE, REFRESH_TOKEN)
|
||||
.param(REFRESH_TOKEN, currentToken.getRefreshToken());
|
||||
|
||||
|
@ -103,10 +103,8 @@ public class TokenManager {
|
|||
try {
|
||||
int requestTime = Time.currentTime();
|
||||
|
||||
synchronized (this) {
|
||||
currentToken = tokenService.refreshToken(config.getRealm(), form.asMap());
|
||||
expirationTime = requestTime + currentToken.getExpiresIn();
|
||||
}
|
||||
return currentToken;
|
||||
} catch (BadRequestException e) {
|
||||
return grantToken();
|
||||
|
@ -126,7 +124,7 @@ public class TokenManager {
|
|||
*
|
||||
* @param token the token to invalidate (cannot be null).
|
||||
*/
|
||||
public void invalidate(String token) {
|
||||
public synchronized void invalidate(String token) {
|
||||
if (currentToken == null) {
|
||||
return; // There's nothing to invalidate.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue