Skip to content

Fix cleanUpExpiredSessions operation in JdbcOperationsSessionRepository #613

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

Closed
wants to merge 2 commits into from

Conversation

vpavic
Copy link
Contributor

@vpavic vpavic commented Sep 4, 2016

Currently, JdbcOperationsSessionRepository#cleanUpExpiredSessions only considers the repository defined max inactive interval which causes incorrect cleanup of sessions that define custom inactive interval. This commit fixes the problem by delegating calculation of deletion interval to the underlying SQL DELETE statement.

Additionally, due to shortcomings in H2 and Derby databases which make them incompatible with newly introduced DELETE statement, the setters for customizing SQL queries have been also added.

This resolves #580 and #609.

@rwinch rwinch self-assigned this Sep 7, 2016
@rwinch rwinch added this to the 1.3.0 M1 milestone Sep 7, 2016
@rwinch rwinch added status: duplicate A duplicate of another issue type: enhancement A general enhancement in: jdbc labels Sep 7, 2016
@rwinch
Copy link
Member

rwinch commented Sep 7, 2016

Thanks for the PR @vpavic!

You can use a single PR, but can you please split the commits into two distinct commits for the specific issues?

I'm wondering if we can improve this slightly so that the JdbcHttpSessionConfiguration detects the Database vendor and updates the query for H2 and Derby using something like:


@Bean
public JdbcOperationsSessionRepository sessionRepository(
        @Qualifier("springSessionJdbcOperations") JdbcTemplate jdbc,
        PlatformTransactionManager transactionManager) throws Exception {
    String vendor = jdbc.getDataSource().getConnection().getMetaData().getDatabaseProductName();
    boolean isH2 = "h2".equalsIgnoreCase(vendor);
        ...

Thoughts?

@rwinch rwinch added the status: waiting-for-feedback We need additional information before we can continue label Sep 7, 2016
@vpavic
Copy link
Contributor Author

vpavic commented Sep 7, 2016

You can use a single PR, but can you please split the commits into two distinct commits for the specific issues?

Done.

I'm wondering if we can improve this slightly so that the JdbcHttpSessionConfiguration detects the Database vendor and updates the query for H2 and Derby

I like the idea. Done as well with the latest PR update.

…itory`

Currently, `JdbcOperationsSessionRepository#cleanUpExpiredSessions` only considers the repository defined max inactive interval which causes incorrect cleanup of sessions that define custom inactive interval. This commit fixes the problem by delegating calculation of deletion interval to the underlying SQL DELETE statement.
@rwinch rwinch removed the status: waiting-for-feedback We need additional information before we can continue label Sep 12, 2016
@rwinch
Copy link
Member

rwinch commented Sep 12, 2016

Thanks for the PR! This is now merged into master

@rwinch rwinch closed this Sep 12, 2016
@vpavic vpavic deleted the gh-580 branch September 12, 2016 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: jdbc status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JdbcOperationsSessionRepository does not respect per Session expiration times
2 participants