diff --git a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java index 48556a60a..08dc99cb5 100644 --- a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java @@ -130,7 +130,10 @@ public class JdbcOperationsSessionRepository implements FindByIndexNameSessionRepository { - private static final String DEFAULT_TABLE_NAME = "SPRING_SESSION"; + /** + * The default name of database table used by Spring Session to store sessions. + */ + public static final String DEFAULT_TABLE_NAME = "SPRING_SESSION"; private static final String SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT"; diff --git a/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/EnableJdbcHttpSession.java b/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/EnableJdbcHttpSession.java index 0cfb4322d..ac6271ddd 100644 --- a/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/EnableJdbcHttpSession.java +++ b/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/EnableJdbcHttpSession.java @@ -24,7 +24,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.session.MapSession; import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession; +import org.springframework.session.jdbc.JdbcOperationsSessionRepository; /** * Add this annotation to an {@code @Configuration} class to expose the @@ -75,7 +77,7 @@ * The name of database table used by Spring Session to store sessions. * @return the database table name */ - String tableName() default ""; + String tableName() default JdbcOperationsSessionRepository.DEFAULT_TABLE_NAME; /** * The session timeout in seconds. By default, it is set to 1800 seconds (30 minutes). @@ -83,6 +85,6 @@ * * @return the seconds a session can be inactive before expiring */ - int maxInactiveIntervalInSeconds() default 1800; + int maxInactiveIntervalInSeconds() default MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS; } diff --git a/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java b/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java index 04f44a0d7..0c6513cb1 100644 --- a/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java +++ b/spring-session/src/main/java/org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.java @@ -54,9 +54,9 @@ public class JdbcHttpSessionConfiguration extends SpringHttpSessionConfiguration implements ImportAware { - private String tableName = ""; + private String tableName; - private Integer maxInactiveIntervalInSeconds = 1800; + private Integer maxInactiveIntervalInSeconds; private LobHandler lobHandler; @@ -116,10 +116,11 @@ public void setMaxInactiveIntervalInSeconds(Integer maxInactiveIntervalInSeconds } private String getTableName() { - if (StringUtils.hasText(this.tableName)) { - return this.tableName; + String systemProperty = System.getProperty("spring.session.jdbc.tableName", ""); + if (StringUtils.hasText(systemProperty)) { + return systemProperty; } - return System.getProperty("spring.session.jdbc.tableName", ""); + return this.tableName; } public void setImportMetadata(AnnotationMetadata importMetadata) {