spring-projects / spring-projects/spring-session

findByPrincipalName does not correctly return sessions

Open
#3,452 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Describe the bug
If you call findByPrincipalName you can get inconstant results, as query listSessionsByPrincipalNameQuery used below does not order results by id. Later, extractor of the result is trying to combine results for the same sessions – but it's calling getLast on list that it's creating, so if results are not ordered, then result list of extractor might have multiple entries for same session. The problem is that later this list is converted to map by id – at this point we will loose some attributes.

To Reproduce
Have two sessions for the same principle name with multiple attributes. Call findByPrincipalName.

Expected behavior
Result should be ordered or extractor should not call getLast but actually look by an id. Also, extractor could return a Set in that case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the codebase for findByPrincipalName and listSessionsByPrincipalNameQuery, then trace the extractor that combines session results. Reproduce the case with two sessions sharing a principal name and multiple attributes. Done means findByPrincipalName consistently returns one complete result per session without losing attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.