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");
* you may not use this file except in compliance with the License.
......@@ -20,7 +20,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.ExpiringSession;
import org.springframework.session.MapSessionRepository;
import org.springframework.session.SessionRepository;
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
......@@ -30,6 +29,7 @@ import org.springframework.session.config.annotation.web.http.EnableSpringHttpSe
*
* @author Tommy Ludwig
* @author Stephane Nicoll
* @author Vedran Pavic
*/
@Configuration
@EnableSpringHttpSession
......@@ -38,8 +38,7 @@ import org.springframework.session.config.annotation.web.http.EnableSpringHttpSe
class HashMapSessionConfiguration {
@Bean
public SessionRepository<ExpiringSession> sessionRepository(
SessionProperties properties) {
public MapSessionRepository sessionRepository(SessionProperties properties) {
MapSessionRepository repository = new MapSessionRepository();
Integer timeout = properties.getTimeout();
if (timeout != null) {
......
......@@ -29,7 +29,6 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.ExpiringSession;
import org.springframework.session.MapSessionRepository;
import org.springframework.session.SessionRepository;
import org.springframework.session.web.http.SessionRepositoryFilter;
......@@ -66,7 +65,7 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
@Test
public void backOffIfSessionRepositoryIsPresent() {
load(Collections.<Class<?>>singletonList(SessionRepositoryConfiguration.class),
load(Collections.singletonList(SessionRepositoryConfiguration.class),
"spring.session.store-type=redis");
MapSessionRepository repository = validateSessionRepository(
MapSessionRepository.class);
......@@ -121,9 +120,8 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
static class SessionRepositoryConfiguration {
@Bean
public SessionRepository<?> mySessionRepository() {
return new MapSessionRepository(
Collections.<String, ExpiringSession>emptyMap());
public MapSessionRepository mySessionRepository() {
return new MapSessionRepository(Collections.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