fix(servicebus): Preserve defaultMessageTimeToLive in subscription updates#48499
Open
EldertGrootenboer wants to merge 1 commit intoAzure:mainfrom
Open
fix(servicebus): Preserve defaultMessageTimeToLive in subscription updates#48499EldertGrootenboer wants to merge 1 commit intoAzure:mainfrom
EldertGrootenboer wants to merge 1 commit intoAzure:mainfrom
Conversation
…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
Contributor
There was a problem hiding this comment.
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
defaultMessageTimeToLiveinAdministrationModelConverter#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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ServiceBusAdministrationClient.updateSubscription()silently ignores changes todefaultMessageTimeToLive. 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()nullifiesdefaultMessageTimeToLivealongside genuinely read-only properties (messageCount,createdAt,updatedAt,accessedAt,messageCountDetails,entityAvailabilityStatus) before serializing the update XML body. SincedefaultMessageTimeToLiveis 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
UserMetadatabeing set tonullon subscription update). ThedefaultMessageTimeToLivewas accidentally included in the read-only property null-out block added by that PR.Fix
Remove
.setDefaultMessageTimeToLive(null)from the null-out chain ingetUpdateSubscriptionBody(). 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 serializesDefaultMessageTimeToLiveas a writable field.Testing
updateSubscriptionPreservesDefaultMessageTimeToLive()unit test that verifies the converter preserves the TTL value in the update body.spotless:check— 0 violations.checkstyle:check— 0 violations.