Skip to content

Commit de4e350

Browse files
committed
Merge branch '1.5.x'
2 parents e9021b3 + 0a26a41 commit de4e350

File tree

4 files changed

+5
-47
lines changed

4 files changed

+5
-47
lines changed

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,11 +16,6 @@
1616

1717
package org.springframework.boot.autoconfigure.session;
1818

19-
import javax.annotation.PostConstruct;
20-
21-
import org.apache.commons.logging.Log;
22-
import org.apache.commons.logging.LogFactory;
23-
2419
import org.springframework.beans.factory.annotation.Autowired;
2520
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2621
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -45,8 +40,6 @@
4540
@Conditional(SessionCondition.class)
4641
class RedisSessionConfiguration {
4742

48-
private static final Log logger = LogFactory.getLog(RedisSessionConfiguration.class);
49-
5043
@Configuration
5144
public static class SpringBootRedisHttpSessionConfiguration
5245
extends RedisHttpSessionConfiguration {
@@ -65,14 +58,6 @@ public void customize(SessionProperties sessionProperties) {
6558
setRedisFlushMode(redis.getFlushMode());
6659
}
6760

68-
@PostConstruct
69-
public void validate() {
70-
if (this.sessionProperties.getStoreType() == null) {
71-
logger.warn("Spring Session store type is mandatory: set "
72-
+ "'spring.session.store-type=redis' in your configuration");
73-
}
74-
}
75-
7661
}
7762

7863
}

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,19 +23,15 @@
2323
import org.springframework.context.annotation.ConditionContext;
2424
import org.springframework.core.type.AnnotatedTypeMetadata;
2525
import org.springframework.core.type.AnnotationMetadata;
26-
import org.springframework.util.ClassUtils;
2726

2827
/**
2928
* General condition used with all session configuration classes.
3029
*
3130
* @author Tommy Ludwig
31+
* @author Stephane Nicoll
3232
*/
3333
class SessionCondition extends SpringBootCondition {
3434

35-
private static final boolean redisPresent = ClassUtils.isPresent(
36-
"org.springframework.data.redis.core.RedisTemplate",
37-
SessionCondition.class.getClassLoader());
38-
3935
@Override
4036
public ConditionOutcome getMatchOutcome(ConditionContext context,
4137
AnnotatedTypeMetadata metadata) {
@@ -46,10 +42,6 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
4642
StoreType sessionStoreType = SessionStoreMappings
4743
.getType(((AnnotationMetadata) metadata).getClassName());
4844
if (!resolver.containsProperty("store-type")) {
49-
if (sessionStoreType == StoreType.REDIS && redisPresent) {
50-
return ConditionOutcome.match(
51-
message.foundExactly("default store type of redis (deprecated)"));
52-
}
5345
return ConditionOutcome.noMatch(
5446
message.didNotFind("spring.session.store-type property").atAll());
5547
}

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,13 +24,10 @@
2424
import org.springframework.beans.DirectFieldAccessor;
2525
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
2626
import org.springframework.boot.redis.RedisTestServer;
27-
import org.springframework.boot.test.rule.OutputCapture;
2827
import org.springframework.session.data.redis.RedisFlushMode;
2928
import org.springframework.session.data.redis.RedisOperationsSessionRepository;
3029

3130
import static org.assertj.core.api.Assertions.assertThat;
32-
import static org.hamcrest.CoreMatchers.not;
33-
import static org.hamcrest.Matchers.containsString;
3431

3532
/**
3633
* Redis specific tests for {@link SessionAutoConfiguration}.
@@ -40,27 +37,14 @@
4037
public class SessionAutoConfigurationRedisTests
4138
extends AbstractSessionAutoConfigurationTests {
4239

43-
@Rule
44-
public OutputCapture output = new OutputCapture();
45-
4640
@Rule
4741
public final RedisTestServer redis = new RedisTestServer();
4842

49-
@Test
50-
public void redisSessionStoreIsTheDefault() {
51-
load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class));
52-
validateSpringSessionUsesRedis();
53-
this.output.expect(containsString(
54-
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"));
55-
}
56-
5743
@Test
5844
public void redisSessionStore() {
5945
load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class),
6046
"spring.session.store-type=redis");
6147
validateSpringSessionUsesRedis();
62-
this.output.expect(not(containsString(
63-
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration")));
6448
}
6549

6650
private void validateSpringSessionUsesRedis() {

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4959,7 +4959,7 @@ Spring Boot provides Spring Session auto-configuration for a wide range of store
49594959
* Hazelcast
49604960
* HashMap
49614961

4962-
If Spring Session is available, you only need to choose the
4962+
If Spring Session is available, you must choose the
49634963
{sc-spring-boot-autoconfigure}/session/StoreType.{sc-ext}[`StoreType`] that you wish to
49644964
use to store the sessions. For instance to use JDBC as backend store, you'd configure
49654965
your application as follows:
@@ -4969,9 +4969,6 @@ your application as follows:
49694969
spring.session.store-type=jdbc
49704970
----
49714971

4972-
NOTE: For backward compatibility if Redis is available Spring Session will be automatically
4973-
configured to use Redis.
4974-
49754972
TIP: You can disable Spring Session by setting the `store-type` to `none`.
49764973

49774974
Each store has specific additional settings. For instance it is possible to customize

0 commit comments

Comments
 (0)