@@ -197,25 +197,14 @@ static <T> Flux<T> cancel(Publisher<List<ByteBuffer>> body) {
197197 });
198198 }
199199
200- /**
201- * Sends {@code request}, handing the response body over as a publisher.
202- *
203- * <p>
204- * Such a body must be subscribed to, or the connection it is read from is never
205- * released. Should the exchange be cancelled once the response has arrived but before
206- * its body could be subscribed to, the response is discarded, and its body cancelled.
207- *
208- * <p>
209- * Cancelling the exchange before the response has arrived aborts the request. The
210- * {@link HttpClient} then fails its future with a {@link CompletionException}
211- * wrapping a {@link CancellationException}, which {@link Mono#fromFuture} does not
212- * recognise as the outcome of its own cancellation and reports as a dropped error.
213- * Only this method can cancel the future, so such a failure is always the expected
214- * outcome of cancelling, and is ignored.
215- * @param httpClient the client to send the request with
216- * @param request the request to send
217- */
218200 static Mono <HttpResponse <Publisher <List <ByteBuffer >>>> sendAsync (HttpClient httpClient , HttpRequest request ) {
201+ // Not Mono.fromFuture: cancelling aborts the exchange, and the HttpClient then
202+ // fails the future with a CompletionException wrapping a CancellationException,
203+ // which fromFuture reports as a dropped error. Only this method cna cancel the
204+ // future, so that failure is ignored here. Replace with a plain fromFuture,
205+ // keeping
206+ // the doOnDiscard, once https://github.com/reactor/reactor-core/issues/4415 is
207+ // resolved.
219208 return Mono .<HttpResponse <Publisher <List <ByteBuffer >>>>create (sink -> {
220209 CompletableFuture <HttpResponse <Publisher <List <ByteBuffer >>>> exchange = httpClient .sendAsync (request ,
221210 HttpResponse .BodyHandlers .ofPublisher ());
@@ -238,11 +227,13 @@ static Mono<HttpResponse<Publisher<List<ByteBuffer>>>> sendAsync(HttpClient http
238227 sink .error (cause );
239228 }
240229 });
241- }).doOnDiscard (HttpResponse .class , response -> {
242- if (response .body () instanceof Publisher <?> body ) {
243- cancelBody (body );
244- }
245- });
230+ })
231+ // A body that is never subscribed to never releases its connection.
232+ .doOnDiscard (HttpResponse .class , response -> {
233+ if (response .body () instanceof Publisher <?> body ) {
234+ cancelBody (body );
235+ }
236+ });
246237 }
247238
248239 private static void cancelBody (Publisher <?> body ) {
0 commit comments