-
Notifications
You must be signed in to change notification settings - Fork 1.1k
JdbcOperationsSessionRepository doesn't resolve delta to correct SQL statement #1070
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
Conversation
Thanks for the PR @candrews - could you please add a test that reproduces the problem i.e. fails before the change you're proposing? |
3df124a
to
c33aef5
Compare
If an attribute is added multiple times, it's delta value should still be ADDED - not UPDATED.
@vpavic I've added a test that passes with this change and fails without it. |
This issue is big problem for me; is there anything I can do to help get it merged so it appears in the next snapshot? |
Thanks for the update @candrews - I'll try to get a closer look at this soon. |
I found a few additional, imho related, issues:
I've added commits to this PR with tests and fixes for those issues. |
I've been testing it with my use case and so far so good - thank you for efforts, I greatly appreciate it 👍 |
I encoutered the same kind of issue while using Spring OAuth2, to persist the authorizationRequest attribute. It was written twice (first in HandlerAdapter.handle, second in DispatcherServlet.processDispatchResult). The issue is also fixed on my side. |
When using JDBC, setting a new attribute multiple times results in an SQL UPDATE not an INSERT. Because there is no row to update, the session attribute is not actually saved to the table.
For example, in a request handler (a Spring MVC controller, servlet, filter, etc):
I would expect a row to be added to the
SPRING_SESSION_ATTRIBUTES
table with theATTRIBUTE_NAME
of "test" and theATTRIBUTE_VALUE
of "someValue"However, what actually happens is that an UPDATE statement is executed resulted in no row being added to
SPRING_SESSION_ATTRIBUTES
.The problem appears to be at https://github.com/spring-projects/spring-session/blob/2.0.3.RELEASE/spring-session-jdbc/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java#L738 - I believe the line should be: