Polishing and minor refactoring

See gh-25884
This commit is contained in:
Rossen Stoyanchev
2020-10-12 11:32:48 +01:00
parent 66138f0dce
commit 5b1b20c8c0
12 changed files with 56 additions and 59 deletions

View File

@@ -65,11 +65,8 @@ public class MockServerHttpResponse extends AbstractServerHttpResponse {
this.writeHandler = body -> {
// 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();
this.body = body.cache();
this.body.subscribe(aVoid -> {}, completion::tryEmitError, completion::tryEmitEmpty); // Signals are serialized
return completion.asMono();
};
}