Skip to content

Align MockHttpServletRequest.isRequestedSessionIdValid() with Servlet 6.1#36671

Open
tianhaocui wants to merge 1 commit intospring-projects:mainfrom
tianhaocui:fix-mock-session-id-valid
Open

Align MockHttpServletRequest.isRequestedSessionIdValid() with Servlet 6.1#36671
tianhaocui wants to merge 1 commit intospring-projects:mainfrom
tianhaocui:fix-mock-session-id-valid

Conversation

@tianhaocui
Copy link
Copy Markdown

Fixes #36631

Summary

MockHttpServletRequest.isRequestedSessionIdValid() currently defaults to true, which does not match the Servlet 6.1 specification.

Changes

  • Changed requestedSessionIdValid field from boolean (default true) to @Nullable Boolean (default null)
  • When not explicitly set via setRequestedSessionIdValid(), isRequestedSessionIdValid() now calculates the return value by checking if the requested session ID matches the current session's ID
  • When explicitly set, the explicit value is used (backward compatible)

Behavior

  • No client session ID (getRequestedSessionId() returns null) -> isRequestedSessionIdValid() returns false
  • After changeSessionId(), requested ID no longer matches -> returns false
  • setRequestedSessionIdValid(true/false) still works as before for explicit control

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 18, 2026
… 6.1

Change requestedSessionIdValid field from boolean (default true) to
@nullable Boolean (default null). When not explicitly set via
setRequestedSessionIdValid(), isRequestedSessionIdValid() now calculates
the return value by checking if the requested session ID matches the
current session's ID, aligning with the Servlet 6.1 specification.

Closes spring-projectsgh-36631

Signed-off-by: cuitianhao <54015884+tianhaocui@users.noreply.github.com>
@tianhaocui tianhaocui force-pushed the fix-mock-session-id-valid branch from 70af16d to 1453996 Compare April 18, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MockHttpServletRequest.isRequestedSessionIdValid() does not follow Servlet 6.1 Javadoc

2 participants