Skip to content

Commit 3b475f9

Browse files
committed
Recover from all refresh-token related errors by requesting a new token
- When the UAA throws an error other than HTTP 401, the refresh token flow fails, and can lead to irrecoverable errors where there application needs to be restarted. This changes ensure we are resilitent to all UAA errors. The downside is that we may not retry using a refresh token when it fails for an unrelated reason (eg HTTP 503), requesting access tokens more frequently. The impact should be extremely marginal. Signed-off-by: Daniel Garnier-Moiroux <daniel.garnier-moiroux@broadcom.com>
1 parent 2b52144 commit 3b475f9

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/tokenprovider/AbstractUaaTokenProvider.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import io.jsonwebtoken.JwtParser;
2626
import io.jsonwebtoken.Jwts;
2727
import io.netty.handler.codec.http.HttpHeaders;
28-
import io.netty.handler.codec.http.HttpResponseStatus;
2928
import io.netty.util.AsciiString;
3029
import java.time.LocalDateTime;
3130
import java.time.ZoneId;
@@ -46,7 +45,6 @@
4645
import org.cloudfoundry.reactor.util.Operator;
4746
import org.cloudfoundry.reactor.util.OperatorContext;
4847
import org.cloudfoundry.reactor.util.UserAgent;
49-
import org.cloudfoundry.uaa.UaaException;
5048
import org.immutables.value.Value;
5149
import org.slf4j.Logger;
5250
import org.slf4j.LoggerFactory;
@@ -253,12 +251,8 @@ private Mono<String> refreshToken(ConnectionContext connectionContext, String re
253251
connectionContext,
254252
refreshTokenGrantTokenRequestTransformer(refreshToken),
255253
tokensExtractor(connectionContext))
256-
.onErrorResume(
257-
t ->
258-
t instanceof UaaException
259-
&& ((UaaException) t).getStatusCode()
260-
== HttpResponseStatus.UNAUTHORIZED.code(),
261-
t -> Mono.empty());
254+
.doOnError(t -> LOGGER.error("Refresh token grant error.", t))
255+
.onErrorResume(t -> Mono.empty());
262256
}
263257

264258
private BiConsumer<HttpClientRequest, HttpClientForm> refreshTokenGrantTokenRequestTransformer(

0 commit comments

Comments
 (0)