Repository navigation
Fix buffer leak in ProtobufDecoder on cancel - #37543
Merged
bclozel merged 1 commit intoOct 22, 2026
Merged
Conversation
ProtobufDecoder released the buffer of a partially read message with doOnTerminate, so only when the input completed or failed. When the subscriber cancelled while a message was split across data buffers, for example after receiving the previous message, that buffer was never released. Use doFinally instead, as AbstractCharSequenceDecoder does, so that the buffer is also released on cancel. Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
bclozel
force-pushed
the
protobuf-decoder-cancel-leak
branch
from
October 22, 2026 08:17
871c680 to
9397e6a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ProtobufDecoder.decode(Publisher)releases the buffer of a partially read message withdoOnTerminate, so only when the input completes or fails. When the subscriber cancels while a message is split across data buffers, for example right after receiving the previous message, that buffer is never released. With pooled buffers, such as Netty's, it leaks.This change uses
doFinallyinstead, asAbstractCharSequenceDecoderdoes, so that the buffer is also released on cancel.The new
ProtobufDecoderTests#decodeCancelWhileMessageIncompletedecodes a data buffer that holds one message and half of the next, then cancels after the first message. Without the change,LeakAwareDataBufferFactoryreports 1 buffer leak. The protobuf codec tests ofspring-weband checkstyle pass.