Skip to content

Commit 51a4eb9

Browse files
valentinEmpytwoseat
authored andcommitted
Configurable retry on invalid token
1 parent b2fb432 commit 51a4eb9

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/ConnectionContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,9 @@ public interface ConnectionContext {
5656
*/
5757
Mono<Void> trust(String host, int port);
5858

59+
/**
60+
* The number of retries after an unsuccessful request
61+
*/
62+
Long getInvalidTokenRetries();
63+
5964
}

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ public Mono<Void> trust(String host, int port) {
146146
.orElse(Mono.empty());
147147
}
148148

149+
@Override
150+
@Value.Default
151+
public Long getInvalidTokenRetries() {
152+
return 5L;
153+
}
154+
149155
/**
150156
* The hostname of the API root. Typically something like {@code api.run.pivotal.io}.
151157
*/

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/util/Operator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ private Flux<HttpClientResponseWithBody> invalidateToken(Flux<HttpClientResponse
206206
private Flux<HttpClientResponseWithBody> processResponse(Flux<HttpClientResponseWithBody> inbound) {
207207
return inbound
208208
.transform(this::invalidateToken)
209-
.retry(t -> t instanceof InvalidTokenException)
209+
.retry(this.context.getConnectionContext().getInvalidTokenRetries(),
210+
t -> t instanceof InvalidTokenException)
210211
.transform(this.context.getErrorPayloadMapper()
211212
.orElse(ErrorPayloadMappers.fallback()));
212213
}

0 commit comments

Comments
 (0)