Skip to content

fix(servicebus): Preserve defaultMessageTimeToLive in subscription updates#48499

Open
EldertGrootenboer wants to merge 1 commit intoAzure:mainfrom
EldertGrootenboer:fix/servicebus-subscription-ttl-48495
Open

fix(servicebus): Preserve defaultMessageTimeToLive in subscription updates#48499
EldertGrootenboer wants to merge 1 commit intoAzure:mainfrom
EldertGrootenboer:fix/servicebus-subscription-ttl-48495

Conversation

@EldertGrootenboer
Copy link
Contributor

Problem

ServiceBusAdministrationClient.updateSubscription() silently ignores changes to defaultMessageTimeToLive. The updated TTL value is discarded before XML serialization, causing the service to revert the property to its default (infinite TimeSpan). No error is thrown.

Fixes #48495

Root Cause

AdministrationModelConverter.getUpdateSubscriptionBody() nullifies defaultMessageTimeToLive alongside genuinely read-only properties (messageCount, createdAt, updatedAt, accessedAt, messageCountDetails, entityAvailabilityStatus) before serializing the update XML body. Since defaultMessageTimeToLive is a writable property that the user explicitly sets, it should not be nullified.

This regression was introduced in v7.17.5 by PR #42332 (which fixed UserMetadata being set to null on subscription update). The defaultMessageTimeToLive was accidentally included in the read-only property null-out block added by that PR.

Fix

Remove .setDefaultMessageTimeToLive(null) from the null-out chain in getUpdateSubscriptionBody(). The remaining null-outs for genuinely read-only properties are correct and unchanged.

This restores the pre-v7.17.5 behavior and aligns with how the .NET SDK handles subscription updates (SubscriptionPropertiesExtensions.cs), which serializes DefaultMessageTimeToLive as a writable field.

Testing

  • Added updateSubscriptionPreservesDefaultMessageTimeToLive() unit test that verifies the converter preserves the TTL value in the update body.
  • Full module test suite: 942 tests run, 0 failures, 0 errors.
  • Formatting: spotless:check — 0 violations.
  • Style: checkstyle:check — 0 violations.

…dates (Azure#48495)

AdministrationModelConverter.getUpdateSubscriptionBody() incorrectly nullified
defaultMessageTimeToLive alongside read-only properties before XML serialization.
This caused updateSubscription() to silently discard TTL changes.

Regression introduced in v7.17.5 by PR Azure#42332 (UserMetadata fix).

Changes:
- Remove erroneous .setDefaultMessageTimeToLive(null) from the read-only
  property null-out block in getUpdateSubscriptionBody()
- Add unit test verifying TTL is preserved through the update body conversion
- Add CHANGELOG entry
Copilot AI review requested due to automatic review settings March 20, 2026 17:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Service Bus administration regression where ServiceBusAdministrationClient.updateSubscription() dropped user-provided defaultMessageTimeToLive during update XML body generation, causing the service to keep/revert TTL unexpectedly.

Changes:

  • Stop nullifying defaultMessageTimeToLive in AdministrationModelConverter#getUpdateSubscriptionBody().
  • Add a regression unit test asserting the update body preserves defaultMessageTimeToLive.
  • Document the bug fix in the module CHANGELOG.

Reviewed changes

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

File Description
sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/AdministrationModelConverter.java Preserves defaultMessageTimeToLive when constructing the subscription update payload.
sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/administration/ServiceBusAdministrationClientTest.java Adds a regression test validating TTL is not nullified in the update body.
sdk/servicebus/azure-messaging-servicebus/CHANGELOG.md Adds an unreleased “Bugs Fixed” entry describing the TTL update fix.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ServiceBusAdministrationClient.updateSubscription() silently ignores defaultMessageTimeToLive changes

3 participants