Skip to content

fix(netty): map connection reset and aborted socket exceptions in NettyUtils - #12

Open
reginaldalfret wants to merge 1 commit into
linkedin:masterfrom
reginaldalfret:fix/netty-connection-reset-decoration
Open

reginaldalfret wants to merge 1 commit into
linkedin:masterfrom
reginaldalfret:fix/netty-connection-reset-decoration

Conversation

@reginaldalfret

Copy link
Copy Markdown

Motivation and Context

In NettyUtils.isConnectionResetException(Throwable), only exceptions containing the literal string "Connection reset by peer" were matched. On many operating systems and JDK implementations, TCP connection resets and abrupt teardowns throw:

  1. java.net.SocketException: Connection reset (standard JDK message without "by peer")
  2. java.io.IOException: An existing connection was forcibly closed by the remote host (Windows WSAECONNRESET 10054)
  3. java.io.IOException: An established connection was aborted by the software in your host machine (Windows WSAECONNABORTED 10053)

Because these cases failed to match isConnectionResetException, NettyUtils.decorateException returned the raw exception without attaching the CLOSED_CHANNEL_ERROR_MESSAGE context (closedChannelMessage(channel)), preventing actionable retry/proxy/TCP-dump diagnostics and causing ServerConnectivityErrorMessageTest cases (DURING_INIT, DURING_SSL_HANDSHAKE) to fail across platforms.

Modifications

  • In NettyUtils.isConnectionResetException:
    • Check if originalCause is an IOException and its message is non-null.
    • Perform case-insensitive matching for "connection reset", "forcibly closed by the remote host", and "connection was aborted".
  • In NettyUtilsTest:
    • Added unit tests covering SocketException("Connection reset"), IOException("An existing connection was forcibly closed by the remote host"), IOException("An established connection was aborted by the software in your host machine"), and lowercase "connection reset".
  • Generated changelog entry in .changes/next-release/.

Testing

  • NettyUtilsTest: 29 tests passed (0 failures, 0 errors).
  • ServerConnectivityErrorMessageTest: all 16 test cases passed (0 failures, 0 errors).
  • Checkstyle: 0 violations.
  • Spotbugs: 0 bugs found.

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

This branch has not been deployed

No deployments
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.

1 participant