-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SessionRepositoryFilter] double save session to repository #2218
Comments
As far as I know, the first commitSession is necessary, as it is intended for committed response. When a response is committed, the first commitSession is called, and the cookie header and other headers are written to the response. Because the response headers can not be modified once a response is commited, we need to do these before the response is committed. |
how are headers and cookies related to the session object in storage? |
In commitSession method of class SessionRepositoryRequestWrapper, HttpSessionIdResolver is used to set session id via cookie or header. This happens before the response is committed. |
@buzzerrookie In our project, we are using redis as the storage, there is one master and two replica.
I have tried adding a conditional break point at the line before if condition, and let it pause a little while when key does not exist. And it turns out no problem(key exists, no exception). I have also tried that remove all my replica of redis, and there is no problem at all. |
Hi, @ravenadesk. I think your issue might be related to #2021 |
@marcusdacoregio |
Hi, @edgar-dev20. Can you provide an example where this might be causing problems for you? We have to make sure that we commit the session when response is committed because after that we might see errors like |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
Expected Behavior
When we use sessionRepositryFilter we find the session once and save it to the repository once at the end of the request
Current Behavior
SessionRepositryFilter at the end of the request find the session 2 times and save it twice. It's all about
spring-session/spring-session-core/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java
Line 181 in c98a7be
Why is this necessary if after all the filters we still make a commit?
spring-session/spring-session-core/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java
Line 146 in c98a7be
Maybe just use the final commit?
The text was updated successfully, but these errors were encountered: