Skip to content

Commit 6e9fbcc

Browse files
committed
Improve PartEvent documentation
Add note about the necessity of consuming the PartEvent content. See gh-29400
1 parent 0ef96b8 commit 6e9fbcc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/docs/asciidoc/web/webflux-functional.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ allPartsEvents.windowUntil(PartEvent::isLast)
259259
}
260260
----
261261

262+
Note that the body contents of the `PartEvent` objects must be completely consumed, relayed, or released to avoid memory leaks.
263+
262264
[[webflux-fn-response]]
263265
=== ServerResponse
264266

src/docs/asciidoc/web/webflux.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,7 +2855,7 @@ For example:
28552855
}
28562856
else if (event instanceof FilePartEvent fileEvent) { <5>
28572857
String filename = fileEvent.filename();
2858-
Flux<DataBuffer> contents = partEvents.map(PartEvent::content);
2858+
Flux<DataBuffer> contents = partEvents.map(PartEvent::content); <6>
28592859
// handle file upload
28602860
}
28612861
else {
@@ -2877,6 +2877,7 @@ split events from all parts into windows that each belong to a single part.
28772877
file upload.
28782878
<4> Handling the form field.
28792879
<5> Handling the file upload.
2880+
<6> The body contents must be completely consumed, relayed, or released to avoid memory leaks.
28802881

28812882
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
28822883
.Kotlin
@@ -2893,7 +2894,7 @@ file upload.
28932894
// handle form field
28942895
} else if (event is FilePartEvent) { <5>
28952896
val filename: String = event.filename();
2896-
val contents: Flux<DataBuffer> = partEvents.map(PartEvent::content);
2897+
val contents: Flux<DataBuffer> = partEvents.map(PartEvent::content); <6>
28972898
// handle file upload
28982899
} else {
28992900
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.
29142915
file upload.
29152916
<4> Handling the form field.
29162917
<5> Handling the file upload.
2918+
<6> The body contents must be completely consumed, relayed, or released to avoid memory leaks.
29172919

29182920
Received part events can also be relayed to another service by using the `WebClient`.
29192921
See <<webflux-client-body-multipart>>.

0 commit comments

Comments
 (0)