Skip to content

StringDecoder.decode() should release chunks on cancellation #30299

Closed
@yunjeffluo

Description

@yunjeffluo

At line 127 of spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java at the main branch, you have
.doOnTerminate(chunks::releaseAndClear)

But chunks won't be released and cleared upon cancellation according to javadoc of reactor-core's reactor.core.publisher.Flux.doOnTerminate():
Add behavior (side-effect) triggered when the Flux terminates, either by completing successfully or failing with an error.

I suggest that you fix this potential memory leak by replacing doOnTerminate() by doFinally() because doFinally() Add behavior (side-effect) triggered after the Flux terminates for any reason, including cancellation.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions