mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Prior to this commit, the reactive `MultipartParser` and `PartGenerator` types were leaking memory at runtime in specific cases: * many HTTP clients must send multipart requests to be parsed and close the connection while uploading * the `PartGenerator` must be configured to write file parts to temporary files on disk * concurrency, upload speed must be important to trigger cases where the file system is not fast enough to consume incoming buffers The `MultipartParser` parses and emits `BodyToken` to its sink (here, the `PartGenerator`). By definition, Reactor's `FluxSink` when created with `Flux.create(FluxSink)` will use a "buffer" strategy and will queue emitted elements if they cannot be consumed. Here, the cancellation signal does dispose internal states in the `MultiPartParser` and `PartGenerator` but does not clear the internal queue in `FluxSink`. This commit ensures that an operation is registered to release buffers on the discard event. Fixes gh-36262