Skip to content

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

Open
EldertGrootenboer wants to merge 4 commits into
Azure:mainfrom
EldertGrootenboer:fix/servicebus-list-sessions-short-page
Open

fix: align list-sessions pagination to .NET short-page termination#49969
EldertGrootenboer wants to merge 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.

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.

2 participants