Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yunjeffluo opened this issue Apr 6, 2023 · 2 comments
Closed

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

yunjeffluo opened this issue Apr 6, 2023 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@yunjeffluo
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 6, 2023
@rstoyanchev rstoyanchev self-assigned this Apr 17, 2023
@rstoyanchev rstoyanchev changed the title StringDecoder.decode() has a memory leak bug StringDecoder.decode() should release chunks on cancellation Apr 17, 2023
@rstoyanchev rstoyanchev added in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 17, 2023
@rstoyanchev rstoyanchev added this to the 6.0.9 milestone Apr 17, 2023
@rstoyanchev
Copy link
Contributor

Thanks for the report. I've also added a test that proved the issue since existing tests were not catching it.

@yunjeffluo
Copy link
Author

yunjeffluo commented May 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants