Remove use of MonoProcessor.fromSinks
See gh-25884
This commit is contained in:
@@ -25,7 +25,6 @@ import java.util.function.Function;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.publisher.MonoProcessor;
|
||||
import reactor.core.publisher.Sinks;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
@@ -64,11 +63,14 @@ public class MockServerHttpResponse extends AbstractServerHttpResponse {
|
||||
public MockServerHttpResponse(DataBufferFactory dataBufferFactory) {
|
||||
super(dataBufferFactory);
|
||||
this.writeHandler = body -> {
|
||||
// Avoid .then() which causes data buffers to be released
|
||||
MonoProcessor<Void> completion = MonoProcessor.fromSink(Sinks.one());
|
||||
this.body = body.doOnComplete(completion::onComplete).doOnError(completion::onError).cache();
|
||||
// Avoid .then() that causes data buffers to be discarded and released
|
||||
Sinks.Empty<Void> completion = Sinks.unsafe().empty();
|
||||
this.body = body
|
||||
.doOnComplete(completion::tryEmitEmpty) // Ignore error: cached + serialized
|
||||
.doOnError(completion::tryEmitError)
|
||||
.cache();
|
||||
this.body.subscribe();
|
||||
return completion;
|
||||
return completion.asMono();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user