diff --git a/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/decorator/BodyCachingServerHttpRequestDecorator.java b/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/decorator/BodyCachingServerHttpRequestDecorator.java index 0289db9..67bf914 100644 --- a/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/decorator/BodyCachingServerHttpRequestDecorator.java +++ b/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/decorator/BodyCachingServerHttpRequestDecorator.java @@ -5,7 +5,6 @@ import java.nio.charset.StandardCharsets; import java.util.stream.Collectors; import lombok.Getter; -import lombok.Setter; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.server.reactive.ServerHttpRequest; @@ -19,9 +18,6 @@ public class BodyCachingServerHttpRequestDecorator extends ServerHttpRequestDeco private final TrafficSelector trafficSelector; private final RequestMetaData requestMetaData; - @Setter - private Runnable onBodyCachedListener; - @Getter private String cachedBody; private boolean bodyCached = false; @@ -68,8 +64,7 @@ public Flux getBody() { cachedBody += dataBuffer.toString(StandardCharsets.UTF_8); }) .doFinally(signalType -> { - if (signalType == SignalType.ON_COMPLETE && onBodyCachedListener != null) { - onBodyCachedListener.run(); + if (signalType == SignalType.ON_COMPLETE) { bodyCached = true; } }); diff --git a/spring-boot-starter/spring-boot-starter-webflux/src/test/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilterTest.java b/spring-boot-starter/spring-boot-starter-webflux/src/test/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilterTest.java index 1a3b8c4..a6572d7 100644 --- a/spring-boot-starter/spring-boot-starter-webflux/src/test/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilterTest.java +++ b/spring-boot-starter/spring-boot-starter-webflux/src/test/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilterTest.java @@ -229,12 +229,6 @@ private void mockDecoratedRequests( when(decoratedRequest.getHeaders()).thenReturn(buildHeadersForBody(configuration.requestBody)); when(decoratedRequest.getCachedBody()).thenReturn(configuration.requestBody); when(decoratedRequest.consumeRequestBody()).thenReturn(Mono.just(configuration.requestBody)); - if (configuration.requestBody != null) { - doAnswer(invocation -> { - invocation.getArgument(0, Runnable.class).run(); - return null; - }).when(decoratedRequest).setOnBodyCachedListener(any()); - } var decoratedResponse = mock(BodyCachingServerHttpResponseDecorator.class); when(decoratorBuilder.buildBodyCachingServerHttpResponseDecorator(response, requestMetaData))