Skip to content

fix: align list-sessions pagination to .NET short-page termination - #49969

Merged
EldertGrootenboer merged 4 commits into
Azure:mainfrom
EldertGrootenboer:fix/servicebus-list-sessions-short-page
Jul 30, 2026
Merged

fix: align list-sessions pagination to .NET short-page termination#49969
EldertGrootenboer merged 4 commits into
Azure:mainfrom
EldertGrootenboer:fix/servicebus-list-sessions-short-page

Conversation

@EldertGrootenboer

Copy link
Copy Markdown
Member

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:

SDK Termination
.NET page.Count < SessionBrowsePageSize
JS nextPageLink: page.length >= top ? ... : undefined
Python len(result) < _PAGE_SIZE
Go len(page) < listSessionsPageSize
Java (this PR) sessionIds.size() < pageSize

Behavior

  • Full page (size == pageSize): continue to the next page.
  • Short or empty page (size < pageSize): stop; the last page's IDs are still returned.
  • Saves one broker round-trip in the common partial-last-page case. An exact-multiple-of-page-size result set still fetches a final empty page (unavoidable).

Changes

  • ServiceBusSessionReceiverAsyncClient.fetchSessionPage terminates on a short page.
  • Public javadoc on both listSessions() overloads and the ServiceBusManagementNode.getMessageSessions contract updated to describe short-page termination.
  • ServiceBusSessionReceiverAsyncClientTest rewritten so each pagination test drives a full first page (exercising the cursor / server-skip logic under short-page termination).

Testing

  • 12/12 ServiceBusSessionReceiverAsyncClientTest tests pass; spotless:check and checkstyle:check clean.

Refinement to the unreleased 7.18.0-beta.3 feature; no new changelog entry.

…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

Copy link
Copy Markdown
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.

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 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.fetchSessionPage to terminate pagination when sessionIds.size() < pageSize.
  • Updated public JavaDoc for listSessions() overloads and the ServiceBusManagementNode.getMessageSessions contract 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.

@EldertGrootenboer

Copy link
Copy Markdown
Member Author

/azp run java - pullrequest

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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.

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.

@EldertGrootenboer
EldertGrootenboer marked this pull request as ready for review July 29, 2026 15:23
@azure-pipelines

Copy link
Copy Markdown
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 j7nw4r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@EldertGrootenboer
EldertGrootenboer merged commit 6de56bc into Azure:main Jul 30, 2026
19 checks passed
@EldertGrootenboer
EldertGrootenboer deleted the fix/servicebus-list-sessions-short-page branch July 30, 2026 21:04
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.

4 participants