diff --git a/src/main/java/jumper/filter/ResponseFilter.java b/src/main/java/jumper/filter/ResponseFilter.java index 6f9e2c2..44c95d4 100644 --- a/src/main/java/jumper/filter/ResponseFilter.java +++ b/src/main/java/jumper/filter/ResponseFilter.java @@ -45,9 +45,10 @@ public GatewayFilter apply(Config config) { (exchange, chain) -> chain .filter(exchange) - .then( - Mono.fromRunnable( - () -> + .doOnTerminate(() -> { + if (exchange.getResponse().isCommitted()) { + return; + } WebFluxSleuthOperators.withSpanInScope( tracer, currentTraceContext, @@ -90,7 +91,8 @@ public GatewayFilter apply(Config config) { } span.event("jrpf"); - }))), + }); + }), RequestFilter.REQUEST_FILTER_ORDER); }