Replaces doOnSuccessOrError with doOnSuccess or doOnError
fixes gh-1538
This commit is contained in:
@@ -70,9 +70,9 @@ public class GatewayMetricsFilter implements GlobalFilter, Ordered {
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
Sample sample = Timer.start(meterRegistry);
|
||||
|
||||
return chain.filter(exchange).doOnSuccessOrError((aVoid, ex) -> {
|
||||
endTimerRespectingCommit(exchange, sample);
|
||||
});
|
||||
return chain.filter(exchange)
|
||||
.doOnSuccess(aVoid -> endTimerRespectingCommit(exchange, sample))
|
||||
.doOnError(throwable -> endTimerRespectingCommit(exchange, sample));
|
||||
}
|
||||
|
||||
private void endTimerRespectingCommit(ServerWebExchange exchange, Sample sample) {
|
||||
|
||||
@@ -238,13 +238,8 @@ public class RetryGatewayFilterFactory
|
||||
// chain.filter returns a Mono<Void>
|
||||
Publisher<Void> publisher = chain.filter(exchange)
|
||||
// .log("retry-filter", Level.INFO)
|
||||
.doOnSuccessOrError((aVoid, throwable) -> {
|
||||
int iteration = exchange
|
||||
.getAttributeOrDefault(RETRY_ITERATION_KEY, -1);
|
||||
int newIteration = iteration + 1;
|
||||
trace("setting new iteration in attr %d", () -> newIteration);
|
||||
exchange.getAttributes().put(RETRY_ITERATION_KEY, newIteration);
|
||||
});
|
||||
.doOnSuccess(aVoid -> updateIteration(exchange))
|
||||
.doOnError(throwable -> updateIteration(exchange));
|
||||
|
||||
if (retry != null) {
|
||||
// retryWhen returns a Mono<Void>
|
||||
@@ -263,6 +258,13 @@ public class RetryGatewayFilterFactory
|
||||
};
|
||||
}
|
||||
|
||||
private void updateIteration(ServerWebExchange exchange) {
|
||||
int iteration = exchange.getAttributeOrDefault(RETRY_ITERATION_KEY, -1);
|
||||
int newIteration = iteration + 1;
|
||||
trace("setting new iteration in attr %d", () -> newIteration);
|
||||
exchange.getAttributes().put(RETRY_ITERATION_KEY, newIteration);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private final void trace(String message, Supplier<Object>... argSuppliers) {
|
||||
if (log.isTraceEnabled()) {
|
||||
|
||||
@@ -175,8 +175,9 @@ public class WebSocketIntegrationTests {
|
||||
.thenMany(session.receive().take(count)
|
||||
.map(WebSocketMessage::getPayloadAsText))
|
||||
.subscribeWith(output).doOnNext(s -> logger.debug("inbound " + s))
|
||||
.then().doOnSuccessOrError((aVoid, ex) -> logger.debug(
|
||||
"Done with " + (ex != null ? ex.getMessage() : "success")));
|
||||
.then().doOnSuccess(aVoid -> logger.debug("Done with success"))
|
||||
.doOnError(ex -> logger.debug(
|
||||
"Done with " + (ex != null ? ex.getMessage() : "error")));
|
||||
}).block(Duration.ofMillis(5000));
|
||||
|
||||
assertThat(output.collectList().block(Duration.ofMillis(5000)))
|
||||
@@ -197,8 +198,9 @@ public class WebSocketIntegrationTests {
|
||||
.thenMany(session.receive().take(count)
|
||||
.map(WebSocketMessage::getPayloadAsText))
|
||||
.subscribeWith(output).doOnNext(s -> logger.debug("inbound " + s))
|
||||
.then().doOnSuccessOrError((aVoid, ex) -> logger.debug(
|
||||
"Done with " + (ex != null ? ex.getMessage() : "success")));
|
||||
.then().doOnSuccess(aVoid -> logger.debug("Done with success"))
|
||||
.doOnError(ex -> logger.debug(
|
||||
"Done with " + (ex != null ? ex.getMessage() : "error")));
|
||||
}).block(Duration.ofMillis(5000));
|
||||
|
||||
assertThat(output.collectList().block(Duration.ofMillis(5000)))
|
||||
|
||||
Reference in New Issue
Block a user