Skip to content

Memory Leak in WebFlux application handling HTTP Multipart #33094

@bugs84

Description

@bugs84

Version
spring-boot version 3.3.1
spring-webflux 6.1.10

Description
In one of our applications, we are facing OutOfMemory error.
We think, that it is connected with Webflux and the upload files using HTTP Multipart requests.

We managed to create a small project with the test, that is able to reproduce issue:
LEAK: ByteBuf.release() was not called before it's garbage-collected.

The project can be found here: https://github.com/bugs84/webflux-leak-02

Basically, there is a controller that accepts multipart and saves it into the files.

   @PostMapping("/upload-files10")
    fun uploadFileWithoutEntity(@RequestPart("files", required = false) filePartFlux: Flux<Part>): Mono<*> {
        return filePartFlux.collectList().flatMap { fileList: List<Part> ->
            Flux.fromIterable(fileList).flatMapSequential { file: Part ->
                val destination = Paths.get("generated_${fileNumber++}.file")
                DataBufferUtils.write(file.content(), destination).then(Mono.just("ok"))
            }.then(Mono.just("OK"))
        }
    }

If we run the test it should generate the mentioned LEAK: issue.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions