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;
|
return currentToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccessTokenResponse refreshToken() {
|
public synchronized AccessTokenResponse refreshToken() {
|
||||||
Form form = new Form().param(GRANT_TYPE, REFRESH_TOKEN)
|
Form form = new Form().param(GRANT_TYPE, REFRESH_TOKEN)
|
||||||
.param(REFRESH_TOKEN, currentToken.getRefreshToken());
|
.param(REFRESH_TOKEN, currentToken.getRefreshToken());
|
||||||
|
|
||||||
|
@ -103,10 +103,8 @@ public class TokenManager {
|
||||||
try {
|
try {
|
||||||
int requestTime = Time.currentTime();
|
int requestTime = Time.currentTime();
|
||||||
|
|
||||||
synchronized (this) {
|
currentToken = tokenService.refreshToken(config.getRealm(), form.asMap());
|
||||||
currentToken = tokenService.refreshToken(config.getRealm(), form.asMap());
|
expirationTime = requestTime + currentToken.getExpiresIn();
|
||||||
expirationTime = requestTime + currentToken.getExpiresIn();
|
|
||||||
}
|
|
||||||
return currentToken;
|
return currentToken;
|
||||||
} catch (BadRequestException e) {
|
} catch (BadRequestException e) {
|
||||||
return grantToken();
|
return grantToken();
|
||||||
|
@ -126,7 +124,7 @@ public class TokenManager {
|
||||||
*
|
*
|
||||||
* @param token the token to invalidate (cannot be null).
|
* @param token the token to invalidate (cannot be null).
|
||||||
*/
|
*/
|
||||||
public void invalidate(String token) {
|
public synchronized void invalidate(String token) {
|
||||||
if (currentToken == null) {
|
if (currentToken == null) {
|
||||||
return; // There's nothing to invalidate.
|
return; // There's nothing to invalidate.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue