Skip to content

Add support for providing a custom SessionTimeout bean#49883

Merged
snicoll merged 2 commits into
spring-projects:mainfrom
bartsopers:customSpringSessionTimeout
Apr 7, 2026
Merged

Add support for providing a custom SessionTimeout bean#49883
snicoll merged 2 commits into
spring-projects:mainfrom
bartsopers:customSpringSessionTimeout

Conversation

@bartsopers
Copy link
Copy Markdown
Contributor

This change allows for customization of Spring Session session timeout in Spring Boot Session.

Closes #49882

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 3, 2026
@snicoll
Copy link
Copy Markdown
Member

snicoll commented Apr 3, 2026

@bartsopers SessionTimeout is a by-product of the modularization and isn't really meant to be overridden by the user (which explains why it doesn't have a condition to override it).

Looking at the implementations, why can't you set the relevant property in the Environment? We'd need more details before discussing the merit of the PR.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue labels Apr 3, 2026
@snicoll snicoll changed the title Add ConditionalOnMissingBean annotations on autoconfigured SessionTimeout beans Add support for providing a custom SessionTimeout bean Apr 3, 2026
@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Apr 7, 2026
@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Apr 7, 2026
@bartsopers
Copy link
Copy Markdown
Contributor Author

@snicoll our use case is that our on-premise customers can configure session management (either Spring Session with redis or servlet container backed sessions) through spring profiles. This would mean that, depending on their configuration and their deployment type (we offer both jar and war artifacts), they would either need to use the server.servlet.session.timeout or the spring.session.timeout property. This is confusing for our customers, so we want to introduce a single property to set the session timeout.
In the Spring Session case, imho, providing a Spring bean would feel more robust than programmatically setting properties in the Environment based on other properties.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Apr 7, 2026
@snicoll
Copy link
Copy Markdown
Member

snicoll commented Apr 7, 2026

@bartsopers fair enough, we can consider this an added value of the modularization.

@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Apr 7, 2026
@snicoll snicoll added this to the 4.1.x milestone Apr 7, 2026
bartsopers and others added 2 commits April 7, 2026 15:04
This commit allows a user-defined SessionTimeout bean to take control
over the auto-configuration of the timeout.

See spring-projectsgh-49883

Signed-off-by: Bart Sopers <15631208+bartsopers@users.noreply.github.com>
@snicoll snicoll force-pushed the customSpringSessionTimeout branch from c3612e7 to b103d2b Compare April 7, 2026 13:10
@snicoll snicoll merged commit e328ca9 into spring-projects:main Apr 7, 2026
1 check failed
@snicoll snicoll modified the milestones: 4.1.x, 4.1.0-RC1 Apr 7, 2026
@snicoll snicoll self-assigned this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom timeout for Spring Session

3 participants