Skip to content

Making a fix to compare sessionid on the message and the sessionid on the link filter in a case-insensitive way.#48759

Open
yvgopal wants to merge 1 commit intoAzure:mainfrom
yvgopal:vijay/session-process-case-sensitivity-fix
Open

Making a fix to compare sessionid on the message and the sessionid on the link filter in a case-insensitive way.#48759
yvgopal wants to merge 1 commit intoAzure:mainfrom
yvgopal:vijay/session-process-case-sensitivity-fix

Conversation

@yvgopal
Copy link
Copy Markdown
Member

@yvgopal yvgopal commented Apr 10, 2026

Service Bus sessionid is not case sensitive. We shouldn't be doing case sensitive comparison between sessionId property on the message and sessionid property on the link.

Copilot AI review requested due to automatic review settings April 10, 2026 02:09
@yvgopal yvgopal requested a review from anuchandy April 10, 2026 02:09
Copy link
Copy Markdown
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

Updates Service Bus session ID matching to be case-insensitive (Service Bus session IDs are not case-sensitive) to avoid disposition/link lookup failures when the broker returns a different session ID casing than the message carries.

Changes:

  • Normalize session ID keys (lowercased with Locale.ROOT) in SessionsMessagePump and ServiceBusSessionManager lookup maps.
  • Switch ServiceBusSingleSessionManager session ID comparisons to equalsIgnoreCase.
  • Add/extend tests to cover case-differing session ID scenarios for message settlement and single-session manager behavior.

Reviewed changes

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

Show a summary per file
File Description
sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/SessionsMessagePump.java Normalizes tracked session receiver keys and disposition lookups to be case-insensitive.
sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusSingleSessionManager.java Uses case-insensitive session ID comparison for link name/disposition routing.
sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusSessionManager.java Normalizes session receiver map keys and lookups for case-insensitive session ID handling.
sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/SessionsMessagePumpIsolatedTest.java Adds a test ensuring settlement succeeds when accepted vs message session ID casing differs.
sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusSingleSessionManagerTest.java Adds new unit tests for case-insensitive link name lookup and disposition update.

import reactor.test.StepVerifier;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Unused static import assertNotNull is never referenced in this test class and will fail compilation (and Checkstyle UnusedImports). Remove the unused import or add an assertion that uses it.

Suggested change
import static org.junit.jupiter.api.Assertions.assertNotNull;

Copilot uses AI. Check for mistakes.
private Flux<ServiceBusMessageContext> getSession(Scheduler scheduler, boolean disposeOnIdle) {
return getActiveLink().flatMap(
link -> link.getSessionId().map(sessionId -> sessionReceivers.compute(sessionId, (key, existing) -> {
link -> link.getSessionId().map(sessionId -> sessionReceivers.compute(sessionId.toLowerCase(Locale.ROOT), (key, existing) -> {
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

This line exceeds the 120-character Checkstyle limit (eng/lintingconfigs/checkstyle/track2/checkstyle.xml enforces max=120) and is likely to fail CI. Please wrap the nested lambdas/compute call across multiple lines for readability and to satisfy LineLength.

Copilot uses AI. Check for mistakes.
Comment on lines 135 to 137
public String getLinkName(String sessionId) {
final ServiceBusSessionReceiver receiver = sessionReceivers.get(sessionId);
final ServiceBusSessionReceiver receiver = sessionReceivers.get(sessionId.toLowerCase(Locale.ROOT));
return receiver != null ? receiver.getLinkName() : null;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

ServiceBusSessionManager now normalizes sessionId keys using toLowerCase(Locale.ROOT) for case-insensitive lookups, but there’s no unit test in ServiceBusSessionManagerTest asserting that getLinkName(...)/updateDisposition(...) work when the caller passes a differently-cased session ID than the stored/accepted one. Adding a focused test would prevent regressions in this behavior.

Copilot generated this review using guidance from repository custom instructions.
@yvgopal
Copy link
Copy Markdown
Member Author

yvgopal commented Apr 10, 2026

@copilot apply changes based on the comments in this thread

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.

3 participants