fix: align list-sessions pagination to .NET short-page termination - #49969
Conversation
…rmination Terminate session enumeration when the broker returns a page smaller than the requested page size (a short or empty page signals the end), matching the .NET SDK's page.Count < SessionBrowsePageSize rule. Previously the async session receiver stopped only on an empty page. Updates the public javadoc on both listSessions() overloads and the ServiceBusManagementNode.getMessageSessions contract, plus the unit tests.
|
Azure Pipelines: Successfully started running 1 pipeline(s). 33 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR updates Service Bus session ID pagination termination in the Java SDK to match the “short page ends enumeration” behavior used by the other Service Bus SDKs (notably .NET): paging stops when the service returns fewer session IDs than the requested page size, rather than requiring an explicitly empty page.
Changes:
- Updated
ServiceBusSessionReceiverAsyncClient.fetchSessionPageto terminate pagination whensessionIds.size() < pageSize. - Updated public JavaDoc for
listSessions()overloads and theServiceBusManagementNode.getMessageSessionscontract to document short-page termination semantics. - Reworked pagination tests to ensure the first page is a full page (so the continuation-token/cursor path is exercised under the new termination rule).
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/ServiceBusSessionReceiverAsyncClient.java | Changes paging termination from “empty page” to “short page” and updates method JavaDoc accordingly. |
| sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ServiceBusManagementNode.java | Updates the management-node contract documentation to describe short-page termination. |
| sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusSessionReceiverAsyncClientTest.java | Updates tests to validate the new termination behavior while still exercising cursor/skip handling. |
|
/azp run java - pullrequest |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 33 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
j7nw4r
left a comment
There was a problem hiding this comment.
The short-page change is right. The backend reasoning you posted on Azure/azure-sdk-for-js#39439 settles the contract question for me. Approving.
One correction to the table. Go on main still ends on an empty page (client.go:550-552), and it got there on purpose in Azure/azure-sdk-for-go#26688 after review feedback. JS #38323 and Python #46575 are open. The table describes the decision you made, ahead of the shipped state. Please reword it, and note that Go needs a follow-up.
The partitioned-entity case is still open. Your reply on the issue describes one stored proc, and it does not mention partitioning. If the broker scans per partition, a short page can arrive before the last partition is read. The client then drops sessions and still reports success. The same question applies to .NET, which already shipped this.
There is also no live test for listSessions in Java. Every test here mocks the management node. A live test on a partitioned session-enabled queue with more than 100 sessions would cover both points.
Summary
Aligns
listSessions()/ get-message-sessions pagination termination with the .NET SDK's short-page rule: enumeration stops when the broker returns a page with fewer session IDs than the requested page size (a short or empty page signals the end), instead of continuing until an explicit empty page.This matches .NET's
if (page.Count < SessionBrowsePageSize) break;and brings all five Service Bus SDKs to identical termination behavior:page.Count < SessionBrowsePageSizenextPageLink: page.length >= top ? ... : undefinedlen(result) < _PAGE_SIZElen(page) < listSessionsPageSizesessionIds.size() < pageSizeBehavior
size == pageSize): continue to the next page.size < pageSize): stop; the last page's IDs are still returned.Changes
ServiceBusSessionReceiverAsyncClient.fetchSessionPageterminates on a short page.listSessions()overloads and theServiceBusManagementNode.getMessageSessionscontract updated to describe short-page termination.ServiceBusSessionReceiverAsyncClientTestrewritten so each pagination test drives a full first page (exercising the cursor / server-skip logic under short-page termination).Testing
ServiceBusSessionReceiverAsyncClientTesttests pass;spotless:checkandcheckstyle:checkclean.Refinement to the unreleased
7.18.0-beta.3feature; no new changelog entry.