From 6e9fbcc24317d31cc3aab81239dd06f52793af88 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 1 Nov 2022 17:20:01 +0100 Subject: [PATCH] Improve PartEvent documentation Add note about the necessity of consuming the PartEvent content. See gh-29400 --- src/docs/asciidoc/web/webflux-functional.adoc | 2 ++ src/docs/asciidoc/web/webflux.adoc | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/docs/asciidoc/web/webflux-functional.adoc b/src/docs/asciidoc/web/webflux-functional.adoc index c34967fbb9d..a7130097bab 100644 --- a/src/docs/asciidoc/web/webflux-functional.adoc +++ b/src/docs/asciidoc/web/webflux-functional.adoc @@ -259,6 +259,8 @@ allPartsEvents.windowUntil(PartEvent::isLast) } ---- +Note that the body contents of the `PartEvent` objects must be completely consumed, relayed, or released to avoid memory leaks. + [[webflux-fn-response]] === ServerResponse diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 423a283d483..254436c2da7 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -2855,7 +2855,7 @@ For example: } else if (event instanceof FilePartEvent fileEvent) { <5> String filename = fileEvent.filename(); - Flux contents = partEvents.map(PartEvent::content); + Flux contents = partEvents.map(PartEvent::content); <6> // handle file upload } else { @@ -2877,6 +2877,7 @@ split events from all parts into windows that each belong to a single part. file upload. <4> Handling the form field. <5> Handling the file upload. +<6> The body contents must be completely consumed, relayed, or released to avoid memory leaks. [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin @@ -2893,7 +2894,7 @@ file upload. // handle form field } else if (event is FilePartEvent) { <5> val filename: String = event.filename(); - val contents: Flux = partEvents.map(PartEvent::content); + val contents: Flux = partEvents.map(PartEvent::content); <6> // handle file upload } else { return Mono.error(RuntimeException("Unexpected event: " + event)); @@ -2914,6 +2915,7 @@ split events from all parts into windows that each belong to a single part. file upload. <4> Handling the form field. <5> Handling the file upload. +<6> The body contents must be completely consumed, relayed, or released to avoid memory leaks. Received part events can also be relayed to another service by using the `WebClient`. See <>.