After receiving the first signal from WebSessionStore#retrieveSession
the subscription on the Mono
is
cancelled which could confuse WebSessionStore
implementations.
The flow currently is: request -> onNext -> cancel -> onComplete After the change the flow is: request -> onNext -> onComplete
Fixes gh-23606.
Author: Andreas Kluth mail@andreaskluth.net
Comment From: rstoyanchev
This is now taking the last session instead of the first session id. The lambda could return first
but instead of reduce
something like this would be more illustrative I think:
.collectList()
.filter(list -> !list.isEmpty())
.map(list -> {
// list.get(0)
// ...
})
Comment From: AndreasKl
@rstoyanchev DefaultWebSessionManagerTests#multipleSessionIds
validates that the last session id is returned. I broke the test when I just returned the first element with Stream#findFirst
which was my obvious first choice. I could replace the reduce
with some variation or most likely more readable with an imperative condition.
I'm not sure if it would be a breaking change when I just return the first element and amend DefaultWebSessionManagerTests#multipleSessionIds
.
Comment From: rstoyanchev
Oh I see. Actually it isn't about the last session id, but rather the first session id for which a session is found. In the test retrieveSession
happens to return empty for the first two.
Given this I'm not sure we could rewrite without cancelling after the first found session. The only alternative would be to try and retrieve all sessions, collectToList, and pick the first.
Comment From: AndreasKl
I think then we should close this PR, as I now understand what the purpose of the code was :-)
Thank you for your time.