spring-session icon indicating copy to clipboard operation
spring-session copied to clipboard

findByPrincipalName does not correctly return sessions

Open dadeloper opened this issue 5 months ago • 1 comments

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.

dadeloper avatar Aug 07 '25 11:08 dadeloper