Skip to content

Fix AMQP remote connection close cleanup#49832

Open
arnabnandy7 wants to merge 7 commits into
Azure:mainfrom
arnabnandy7:fix/netty-memory-leak
Open

Fix AMQP remote connection close cleanup#49832
arnabnandy7 wants to merge 7 commits into
Azure:mainfrom
arnabnandy7:fix/netty-memory-leak

Conversation

@arnabnandy7

Copy link
Copy Markdown
Contributor

Description

Fixes an azure-core-amqp connection cleanup issue when a remote endpoint closes an AMQP connection with an error condition, such as amqp:connection:forced.

Previously, ConnectionHandler suppressed the error because the remote endpoint was already in the CLOSED state. As a result, ReactorConnection did not receive a terminal signal and could retain connection and transport resources across reconnects.

This change:

  • Emits the mapped AmqpException for error-bearing remote connection closes.
  • Preserves the existing CLOSED signal for graceful remote closes.
  • Adds regression tests for graceful and amqp:connection:forced closes.
  • Updates the azure-core-amqp changelog.

Fixes #49440.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Test validation: ConnectionHandlerTest - 9 tests passed with no failures or errors.

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
Copilot AI review requested due to automatic review settings July 15, 2026 22:26
@arnabnandy7
arnabnandy7 requested review from a team and conniey as code owners July 15, 2026 22:26
@github-actions github-actions Bot added Azure.Core.AMQP azure-core-amqp Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution @arnabnandy7! We will review the pull request and get back to you soon.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
34 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

Pull request overview

This pull request fixes an azure-core-amqp cleanup/termination issue when the remote AMQP peer closes the connection with an error condition (for example amqp:connection:forced). The change ensures the ConnectionHandler emits a terminal error signal (mapped to AmqpException) instead of suppressing it when the remote endpoint is already CLOSED, helping avoid retaining connection/transport resources across reconnect cycles.

Changes:

  • Emit a mapped terminal error (AmqpException) from onConnectionRemoteClose when the remote close includes an AMQP error condition.
  • Preserve existing behavior for graceful remote closes (still emits EndpointState.CLOSED).
  • Add regression tests covering both graceful remote close and amqp:connection:forced remote close, and update the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/handler/ConnectionHandler.java Ensures remote close events with an error condition surface a terminal error instead of being suppressed.
sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/handler/ConnectionHandlerTest.java Adds regression tests for remote close signaling behavior (graceful vs error-bearing close).
sdk/core/azure-core-amqp/CHANGELOG.md Documents the bug fix in the upcoming unreleased version.

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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

Labels

Azure.Core.AMQP azure-core-amqp Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Possible memory leak azure-sdk-bom 1.3.6 with netty 4.1.134-FINAL

2 participants