Skip to content

Commit a347a78

Browse files
committed
Polish contribution
Closes gh-6649
1 parent 9141177 commit a347a78

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,21 @@ public Initializer getInitializer() {
144144
public class Initializer {
145145

146146
/**
147-
* Create the required session tables on startup if necessary.
147+
* Create the required session tables on startup if necessary. Enabled
148+
* automatically if the default table name is set or a custom schema is
149+
* configured.
148150
*/
149-
private boolean enabled = true;
151+
private Boolean enabled;
150152

151153
public boolean isEnabled() {
152-
boolean isDefaultTableName = DEFAULT_TABLE_NAME.equals(
154+
if (this.enabled != null) {
155+
return this.enabled;
156+
}
157+
boolean defaultTableName = DEFAULT_TABLE_NAME.equals(
153158
Jdbc.this.getTableName());
154-
boolean isDefaultSchema = DEFAULT_SCHEMA_LOCATION.equals(
159+
boolean customSchema = !DEFAULT_SCHEMA_LOCATION.equals(
155160
Jdbc.this.getSchema());
156-
return this.enabled && (isDefaultTableName || !isDefaultSchema);
161+
return (defaultTableName || customSchema);
157162
}
158163

159164
public void setEnabled(boolean enabled) {

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ content into your application; rather pick only the properties that you need.
369369
370370
# SPRING SESSION ({sc-spring-boot-autoconfigure}/session/SessionProperties.{sc-ext}[SessionProperties])
371371
spring.session.hazelcast.map-name=spring:session:sessions # Name of the map used to store sessions.
372-
spring.session.jdbc.initializer.enabled=true # Create the required session tables on startup if necessary.
372+
spring.session.jdbc.initializer.enabled= # Create the required session tables on startup if necessary. Enabled automatically if the default table name is set or a custom schema is configured.
373373
spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
374374
spring.session.jdbc.table-name=SPRING_SESSION # Name of database table used to store sessions.
375375
spring.session.mongo.collection-name=sessions # Collection name used to store sessions.

0 commit comments

Comments
 (0)