Commit 1bf7558a authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #9145 from vpavic:align-session-2.0

* pr/9145:
  Improve `HashMapSessionConfiguration`
parents 527c2e7b 94f96a28
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,7 +20,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean ...@@ -20,7 +20,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.session.ExpiringSession;
import org.springframework.session.MapSessionRepository; import org.springframework.session.MapSessionRepository;
import org.springframework.session.SessionRepository; import org.springframework.session.SessionRepository;
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession; import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
...@@ -30,6 +29,7 @@ import org.springframework.session.config.annotation.web.http.EnableSpringHttpSe ...@@ -30,6 +29,7 @@ import org.springframework.session.config.annotation.web.http.EnableSpringHttpSe
* *
* @author Tommy Ludwig * @author Tommy Ludwig
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Vedran Pavic
*/ */
@Configuration @Configuration
@EnableSpringHttpSession @EnableSpringHttpSession
...@@ -38,8 +38,7 @@ import org.springframework.session.config.annotation.web.http.EnableSpringHttpSe ...@@ -38,8 +38,7 @@ import org.springframework.session.config.annotation.web.http.EnableSpringHttpSe
class HashMapSessionConfiguration { class HashMapSessionConfiguration {
@Bean @Bean
public SessionRepository<ExpiringSession> sessionRepository( public MapSessionRepository sessionRepository(SessionProperties properties) {
SessionProperties properties) {
MapSessionRepository repository = new MapSessionRepository(); MapSessionRepository repository = new MapSessionRepository();
Integer timeout = properties.getTimeout(); Integer timeout = properties.getTimeout();
if (timeout != null) { if (timeout != null) {
......
...@@ -29,7 +29,6 @@ import org.springframework.beans.factory.BeanCreationException; ...@@ -29,7 +29,6 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.session.ExpiringSession;
import org.springframework.session.MapSessionRepository; import org.springframework.session.MapSessionRepository;
import org.springframework.session.SessionRepository; import org.springframework.session.SessionRepository;
import org.springframework.session.web.http.SessionRepositoryFilter; import org.springframework.session.web.http.SessionRepositoryFilter;
...@@ -66,7 +65,7 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat ...@@ -66,7 +65,7 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
@Test @Test
public void backOffIfSessionRepositoryIsPresent() { public void backOffIfSessionRepositoryIsPresent() {
load(Collections.<Class<?>>singletonList(SessionRepositoryConfiguration.class), load(Collections.singletonList(SessionRepositoryConfiguration.class),
"spring.session.store-type=redis"); "spring.session.store-type=redis");
MapSessionRepository repository = validateSessionRepository( MapSessionRepository repository = validateSessionRepository(
MapSessionRepository.class); MapSessionRepository.class);
...@@ -121,9 +120,8 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat ...@@ -121,9 +120,8 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
static class SessionRepositoryConfiguration { static class SessionRepositoryConfiguration {
@Bean @Bean
public SessionRepository<?> mySessionRepository() { public MapSessionRepository mySessionRepository() {
return new MapSessionRepository( return new MapSessionRepository(Collections.emptyMap());
Collections.<String, ExpiringSession>emptyMap());
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment