Skip to content

Commit

Permalink
remove now useless Runnable
Browse files Browse the repository at this point in the history
  • Loading branch information
pboos committed Nov 23, 2023
1 parent 58e0d9e commit bc48832
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -68,8 +64,7 @@ public Flux<DataBuffer> 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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit bc48832

Please sign in to comment.