Skip to content

Commit 4057dd1

Browse files
committed
Change preference of session store implementations
The order has been determined based on usage statistics. Closes gh-27756
1 parent 6f65777 commit 4057dd1

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ DefaultCookieSerializerCustomizer rememberMeServicesCookieSerializerCustomizer()
116116

117117
@Configuration(proxyBeanMethods = false)
118118
@ConditionalOnMissingBean(SessionRepository.class)
119-
@Import({ RedisSessionConfiguration.class, MongoSessionConfiguration.class, HazelcastSessionConfiguration.class,
120-
JdbcSessionConfiguration.class })
119+
@Import({ RedisSessionConfiguration.class, JdbcSessionConfiguration.class, HazelcastSessionConfiguration.class,
120+
MongoSessionConfiguration.class })
121121
static class ServletSessionRepositoryConfiguration {
122122

123123
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationHazelcastTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ void defaultConfig() {
5858
}
5959

6060
@Test
61-
void hazelcastTakesPrecedenceOverJdbc() {
61+
void hazelcastTakesPrecedenceOverMongo() {
6262
this.contextRunner.withClassLoader(
63-
new FilteredClassLoader(RedisIndexedSessionRepository.class, MongoIndexedSessionRepository.class))
63+
new FilteredClassLoader(RedisIndexedSessionRepository.class, JdbcIndexedSessionRepository.class))
6464
.run(this::validateDefaultConfig);
6565
}
6666

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ void defaultConfig() {
7474
this.contextRunner.run(this::validateDefaultConfig);
7575
}
7676

77+
@Test
78+
void jdbcTakesPrecedenceOverMongoAndHazelcast() {
79+
this.contextRunner.withClassLoader(new FilteredClassLoader(RedisIndexedSessionRepository.class))
80+
.run(this::validateDefaultConfig);
81+
}
82+
7783
private void validateDefaultConfig(AssertableWebApplicationContext context) {
7884
JdbcIndexedSessionRepository repository = validateSessionRepository(context,
7985
JdbcIndexedSessionRepository.class);

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationMongoTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ void defaultConfig() {
6363
this.contextRunner.run(validateSpringSessionUsesMongo("sessions"));
6464
}
6565

66-
@Test
67-
void mongoTakesPrecedenceOverJdbcAndHazelcast() {
68-
this.contextRunner.withClassLoader(new FilteredClassLoader(RedisIndexedSessionRepository.class))
69-
.run(validateSpringSessionUsesMongo("sessions"));
70-
}
71-
7266
@Test
7367
void defaultConfigWithCustomTimeout() {
7468
this.contextRunner.withPropertyValues("spring.session.timeout=1m")

spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-session.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Spring Boot provides {spring-session}[Spring Session] auto-configuration for a w
44
When building a servlet web application, the following stores can be auto-configured:
55

66
* Redis
7-
* MongoDB
8-
* Hazelcast
97
* JDBC
8+
* Hazelcast
9+
* MongoDB
1010

1111
Additionally, {spring-boot-for-apache-geode}[Spring Boot for Apache Geode] provides {spring-boot-for-apache-geode-docs}#geode-session[auto-configuration for using Apache Geode as a session store].
1212

@@ -16,10 +16,10 @@ If a single Spring Session module is present on the classpath, Spring Boot uses
1616
If you have more than one implementation, Spring Boot uses the following order for choosing a specific implementation:
1717

1818
. Redis
19-
. MongoDB
20-
. Hazelcast
2119
. JDBC
22-
. If none of Redis, MongoDB, Hazelcast and JDBC are available, we do not configure a `SessionRepository`.
20+
. Hazelcast
21+
. MongoDB
22+
. If none of Redis, JDBC, Hazelcast and MongoDB are available, we do not configure a `SessionRepository`.
2323

2424

2525
When building a reactive web application, the following stores can be auto-configured:

0 commit comments

Comments
 (0)