Skip to content

Close channel on TLS exception to prevent half-open connections#16202

Open
uuuyuqi wants to merge 2 commits intoapache:3.3from
uuuyuqi:fix/ssl-server-tls-handler-exception-swallowed
Open

Close channel on TLS exception to prevent half-open connections#16202
uuuyuqi wants to merge 2 commits intoapache:3.3from
uuuyuqi:fix/ssl-server-tls-handler-exception-swallowed

Conversation

@uuuyuqi
Copy link
Copy Markdown

@uuuyuqi uuuyuqi commented Apr 9, 2026

What is the purpose of the change?

Fixes #16201

SslServerTlsHandler.exceptionCaught() only logged errors without closing the channel or propagating the exception. This caused channels to remain TCP-active but application-dead (half-open) when non-IOException/non-OutOfMemoryError exceptions (e.g., NoClassDefFoundError) occurred during Netty's read loop.

Impact: Consumer-side DubboInvoker.isAvailable() always returned true for these broken connections (it only checks TCP-level channel.isActive()), so the addInvalidateInvoker mechanism never triggered. The broken Provider was never removed from validInvokers, causing continuous RPC timeouts.

Changes:

  • SslServerTlsHandler.exceptionCaught(): Added ctx.close() after logging, consistent with the userEventTriggered() method in the same class which already closes the channel on TLS handshake failure.
  • SslClientTlsHandler.userEventTriggered(): Changed from ctx.fireExceptionCaught() to ctx.close() on handshake failure, consistent with server-side behavior and ensuring the channel is properly closed so the Consumer can detect the failure.

Checklist

Made with Cursor

uuuyuqi added 2 commits April 9, 2026 17:48
SslServerTlsHandler.exceptionCaught() only logged the error without
closing the channel or propagating the exception. This caused channels
to remain TCP-active but application-dead when exceptions like
NoClassDefFoundError occurred during Netty read loops.

Similarly, SslClientTlsHandler did not close the channel on TLS
handshake failure, only firing exceptionCaught to downstream handlers.

This fix ensures both handlers close the channel on failure, allowing
Dubbo's existing health-check mechanism (isAvailable/addInvalidateInvoker)
to properly detect and remove broken invokers.

Change-Id: Ia466bc4db9e59b1f5c1f01a3062c619aabbbb4e1
Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ie3ac6e2e6d1ce5e8f6bd2ad4fe2a5c9286d66fbf
Co-developed-by: Cursor <noreply@cursor.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.78%. Comparing base (8814afa) to head (1ab3c38).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16202      +/-   ##
============================================
- Coverage     60.79%   60.78%   -0.01%     
  Complexity    11751    11751              
============================================
  Files          1953     1953              
  Lines         89119    89120       +1     
  Branches      13444    13444              
============================================
- Hits          54177    54171       -6     
  Misses        29368    29368              
- Partials       5574     5581       +7     
Flag Coverage Δ
integration-tests-java21 32.16% <0.00%> (+0.03%) ⬆️
integration-tests-java8 32.21% <0.00%> (+0.03%) ⬆️
samples-tests-java21 32.10% <0.00%> (-0.08%) ⬇️
samples-tests-java8 29.74% <0.00%> (-0.08%) ⬇️
unit-tests-java11 59.03% <100.00%> (+0.01%) ⬆️
unit-tests-java17 58.52% <100.00%> (-0.02%) ⬇️
unit-tests-java21 58.55% <100.00%> (+0.02%) ⬆️
unit-tests-java25 58.50% <100.00%> (+0.02%) ⬆️
unit-tests-java8 59.04% <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 Sentry.
📢 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.

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.

[Bug] SslServerTlsHandler.exceptionCaught() swallows exceptions without closing channel, causing permanent half-open TLS connections

2 participants