At present, the insert of new attributes in JdbcOperationsSessionRepository is done unconditionally. This can cause data integrity violation errors with concurrent requests, where one request attempts to add new session attribute while the other, concurrent request, deletes the session.
This commit addresses the described scenario by executing insert of new attributes conditionally on presence of parent record.
Closes gh-1031
Currently, Session#getAttributeNames implementations, by delegating to MapSession, all return a session attribute map's key set. This causes ConcurrentModificationException when an attempt to modify session attributes is made while iterating over the returned attribute names.
Closes gh-1120
This commit optimizes session attribute saving by ensuring batch updates are used whenever possible. To make this possible, delta now tracks operations for each attribute change in order to be able to deduce SQL operation.
Additionally, if there is only a single attribute change, regular update is executed rather than batch operation.
Closes gh-1051
Previously, SessionResultSetExtractor used JdbcSession.setAttribute which had a side effect of freshly loaded session potentially having a non-empty delta and/or changed flag set. This commit optimizes session retrieval to invoke setAttribute directly on the delegate, therefore preventing unnecessary modifications of delta and change flags.
Closes gh-1042
This commit improves JDBC configuration by introducing `@SpringSessionDataSource` qualifier for explicitly declaring a `DataSource` to be used by Spring Session. This is in particular useful in scenarios with multiple `DataSource` beans present in the application context.
As a consequence, JDBC configuration is simplified and no longer registers a Spring Session specific `JdbcTemplate` bean.
Closes gh-863
This commit improves session cleanup handling in `JdbcOperationsSessionRepository#cleanUpExpiredSessions` by optimizing the used SQL statement. This is done by calculating the session expiry time when persisting the session, which in turn allows the cleanup SQL statement to be more index-friendly.
Closes gh-847
This commit improves dependency management with the following changes:
- `spring-session-core`: move `javax.servlet-api` from `provided` to `optional` configuration due to introduction of reactive support
- `spring-session-data-redis`: remove Redis driver from `compile` configuration
- Boot samples: delegate Redis driver choice to `spring-boot-starter-data-redis`
- polish `test` configuration dependencies