Skip to content

Simplify expired session cleanup jobs - #2163

Merged
rwinch merged 1 commit into
spring-projects:mainfrom
vpavic:gh-2136
Sep 23, 2022
Merged

rwinch merged 1 commit into
spring-projects:mainfrom
vpavic:gh-2136

Conversation

@vpavic

@vpavic vpavic commented Sep 20, 2022

Copy link
Copy Markdown
Contributor

At present, RedisIndexedHttpSessionConfiguration and JdbcHttpSessionConfiguration include @EnableScheduling annotated inner configuration classes that configure expired session cleanup jobs. This approach silently opts in users into general purpose task scheduling support provided by Spring Framework, which isn't something a library should do. Ideally, session cleanup jobs should only require a single thread dedicated to their execution and also one that doesn't compete for resources with general purpose task scheduling.

This PR updates RedisIndexedSessionRepository and JdbcIndexedSessionRepository to have them manage their own ThreadPoolTaskScheduler for purposes of running expired session cleanup jobs.

Closes gh-2136

@rwinch rwinch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that we don't rely on @PostConstruct/@PostDestroy for Beans as this means that the class must be instantiated by a container in order to be used. Instead, I'd consider using InitializingBean and DisposableBean

At present, RedisIndexedHttpSessionConfiguration and JdbcHttpSessionConfiguration include [at]EnableScheduling annotated inner configuration classes that configure expired session cleanup jobs. This approach silently opts in users into general purpose task scheduling support provided by Spring Framework, which isn't something a library should do. Ideally, session cleanup jobs should only require a single thread dedicated to their execution and also one that doesn't compete for resources with general purpose task scheduling.

This commit updates RedisIndexedSessionRepository and JdbcIndexedSessionRepository to have them manage their own ThreadPoolTaskScheduler for purposes of running expired session cleanup jobs.

Closes spring-projectsgh-2136
@rwinch
rwinch merged commit 954a40f into spring-projects:main Sep 23, 2022
@rwinch

rwinch commented Sep 23, 2022

Copy link
Copy Markdown
Member

Thanks for the Pull Request! This is now merged into main 😄

@vpavic
vpavic deleted the gh-2136 branch September 23, 2022 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: redis type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify session cleanup related scheduled jobs

2 participants