Skip to content

[ISSUE #16399] Close late input after DefaultStreamingDecoder shutdown - #16406

Open
cyforkk wants to merge 2 commits into
apache:3.3from
cyforkk:fix/16399-default-streaming-decoder-bytebuf-leak
Open

[ISSUE #16399] Close late input after DefaultStreamingDecoder shutdown#16406
cyforkk wants to merge 2 commits into
apache:3.3from
cyforkk:fix/16399-default-streaming-decoder-bytebuf-leak

Conversation

@cyforkk

@cyforkk cyforkk commented Jul 31, 2026

Copy link
Copy Markdown

Fixes #16399

What is the purpose of the change

DefaultStreamingDecoder.decode() does not close the input stream when the decoder has already been closed (closed == true). In the Triple HTTP/2 path, DATA frames are wrapped in ByteBufInputStream(content, true) (i.e., releaseOnClose = true), meaning the underlying pooled ByteBuf is released only when InputStream.close() is called. If a late DATA frame arrives asynchronously after the decoder has started closing, the ByteBuf is never released, causing a leak.

This is the exact same bug pattern as #16389, which was fixed by #16391 for LengthFieldStreamingDecoder. This PR mirrors that fix for DefaultStreamingDecoder.

Brief changelog

  • Close input streams received in decode() when the decoder is closed.
  • Propagate input close failures as DecodeException.
  • Add regression coverage for both close() and onStreamClosed() decoder states.

Verifying this change

  • DefaultStreamingDecoderTest: 2 tests passed.
  • LengthFieldStreamingDecoderTest: 2 tests passed.
  • All dubbo-remoting-http12 tests: 23 tests passed, 2 skipped.

…hutdown

Mirror the apache#16391 fix: when decode() is called after the decoder has
been closed (via close() or onStreamClosed()), close the input stream
instead of ignoring it. This prevents ByteBuf leaks in the non-gRPC
Triple HTTP/2 streaming path when late DATA frames arrive after the
decoder has started closing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.91%. Comparing base (3a30432) to head (64aa67b).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16406      +/-   ##
============================================
+ Coverage     60.87%   60.91%   +0.03%     
+ Complexity    11766    11761       -5     
============================================
  Files          1953     1953              
  Lines         89273    89277       +4     
  Branches      13473    13473              
============================================
+ Hits          54346    54382      +36     
+ Misses        29333    29303      -30     
+ Partials       5594     5592       -2     
Flag Coverage Δ
integration-tests-java21 32.08% <0.00%> (-0.06%) ⬇️
integration-tests-java8 32.21% <0.00%> (+<0.01%) ⬆️
samples-tests-java21 32.09% <0.00%> (-0.11%) ⬇️
samples-tests-java8 29.73% <0.00%> (-0.06%) ⬇️
unit-tests-java11 59.14% <100.00%> (+0.02%) ⬆️
unit-tests-java17 58.60% <100.00%> (-0.04%) ⬇️
unit-tests-java21 58.64% <100.00%> (+0.03%) ⬆️
unit-tests-java25 58.57% <100.00%> (+0.01%) ⬆️
unit-tests-java8 59.14% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Cover the IOException -> DecodeException branch to improve patch coverage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@LI123456mo LI123456mo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DefaultStreamingDecoder ByteBuf leak when decode() is called after close

3 participants