diff --git a/docs/src/docs/asciidoc/index.adoc b/docs/src/docs/asciidoc/index.adoc index de808872..361498e0 100644 --- a/docs/src/docs/asciidoc/index.adoc +++ b/docs/src/docs/asciidoc/index.adoc @@ -416,7 +416,7 @@ include::{docs-test-dir}docs/security/SecurityConfiguration.java[tags=class] ---- This assumes that you've also configured Spring Session to provide a `FindByIndexNameSessionRepository` that -returns `ExpiringSession` instances. +returns `Session` instances. When using XML configuration, it would look something like this: [source,xml,indent=0] @@ -458,11 +458,7 @@ include::{indexdoc-tests}[tags=repository-demo] <5> We retrieve the `Session` from the `SessionRepository`. <6> We obtain the persisted `User` from our `Session` without the need for explicitly casting our attribute. -[[api-expiringsession]] -=== ExpiringSession - -An `ExpiringSession` extends a `Session` by providing attributes related to the `Session` instance's expiration. -If there is no need to interact with the expiration information, prefer using the more simple `Session` API. +`Session` API also provides attributes related to the `Session` instance's expiration. Typical usage might look like the following: @@ -471,17 +467,17 @@ Typical usage might look like the following: include::{indexdoc-tests}[tags=expire-repository-demo] ---- -<1> We create a `SessionRepository` instance with a generic type, `S`, that extends `ExpiringSession`. The generic type is defined in our class. -<2> We create a new `ExpiringSession` using our `SessionRepository` and assign it to a variable of type `S`. -<3> We interact with the `ExpiringSession`. -In our example, we demonstrate updating the amount of time the `ExpiringSession` can be inactive before it expires. -<4> We now save the `ExpiringSession`. +<1> We create a `SessionRepository` instance with a generic type, `S`, that extends `Session`. The generic type is defined in our class. +<2> We create a new `Session` using our `SessionRepository` and assign it to a variable of type `S`. +<3> We interact with the `Session`. +In our example, we demonstrate updating the amount of time the `Session` can be inactive before it expires. +<4> We now save the `Session`. This is why we needed the generic type `S`. -The `SessionRepository` only allows saving `ExpiringSession` instances that were created or retrieved using the same `SessionRepository`. +The `SessionRepository` only allows saving `Session` instances that were created or retrieved using the same `SessionRepository`. This allows for the `SessionRepository` to make implementation specific optimizations (i.e. only writing attributes that have changed). -The last accessed time is automatically updated when the `ExpiringSession` is saved. -<5> We retrieve the `ExpiringSession` from the `SessionRepository`. -If the `ExpiringSession` were expired, the result would be null. +The last accessed time is automatically updated when the `Session` is saved. +<5> We retrieve the `Session` from the `SessionRepository`. +If the `Session` were expired, the result would be null. [[api-sessionrepository]] === SessionRepository @@ -640,7 +636,7 @@ HMSET spring:session:sessions:33fdd1b6-b496-4b33-9f7d-df96679d32fe sessionAttr:a [[api-redisoperationssessionrepository-expiration]] ===== Session Expiration -An expiration is associated to each session using the EXPIRE command based upon the `ExpiringSession.getMaxInactiveInterval()`. +An expiration is associated to each session using the EXPIRE command based upon the `Session.getMaxInactiveInterval()`. For example: ---- @@ -776,7 +772,7 @@ redis 127.0.0.1:6379> hget spring:session:sessions:4fc39ce3-63b3-4e17-b1c4-5e1ed [[api-mapsessionrepository]] === MapSessionRepository -The `MapSessionRepository` allows for persisting `ExpiringSession` in a `Map` with the key being the `ExpiringSession` id and the value being the `ExpiringSession`. +The `MapSessionRepository` allows for persisting `Session` in a `Map` with the key being the `Session` id and the value being the `Session`. The implementation can be used with a `ConcurrentHashMap` as a testing or convenience mechanism. Alternatively, it can be used with distributed `Map` implementations. For example, it can be used with Hazelcast. diff --git a/docs/src/test/java/docs/HttpSessionConfigurationNoOpConfigureRedisActionXmlTests.java b/docs/src/test/java/docs/HttpSessionConfigurationNoOpConfigureRedisActionXmlTests.java index 9b4d33c4..e63dad53 100644 --- a/docs/src/test/java/docs/HttpSessionConfigurationNoOpConfigureRedisActionXmlTests.java +++ b/docs/src/test/java/docs/HttpSessionConfigurationNoOpConfigureRedisActionXmlTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -21,7 +21,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.web.http.SessionRepositoryFilter; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -38,7 +38,7 @@ import static org.mockito.Mockito.mock; @WebAppConfiguration public class HttpSessionConfigurationNoOpConfigureRedisActionXmlTests { @Autowired - SessionRepositoryFilter filter; + SessionRepositoryFilter filter; @Test public void redisConnectionFactoryNotUsedSinceNoValidation() { diff --git a/docs/src/test/java/docs/IndexDocTests.java b/docs/src/test/java/docs/IndexDocTests.java index 836ff150..6704f62d 100644 --- a/docs/src/test/java/docs/IndexDocTests.java +++ b/docs/src/test/java/docs/IndexDocTests.java @@ -26,7 +26,6 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.mock.web.MockServletContext; -import org.springframework.session.ExpiringSession; import org.springframework.session.MapSession; import org.springframework.session.MapSessionRepository; import org.springframework.session.Session; @@ -49,7 +48,7 @@ public class IndexDocTests { @Test public void repositoryDemo() { - RepositoryDemo demo = new RepositoryDemo<>(); + RepositoryDemo demo = new RepositoryDemo<>(); demo.repository = new MapSessionRepository(); demo.demo(); @@ -81,14 +80,14 @@ public class IndexDocTests { @Test public void expireRepositoryDemo() { - ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo<>(); + ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo<>(); demo.repository = new MapSessionRepository(); demo.demo(); } // tag::expire-repository-demo[] - public class ExpiringRepositoryDemo { + public class ExpiringRepositoryDemo { private SessionRepository repository; // <1> public void demo() { @@ -111,7 +110,7 @@ public class IndexDocTests { public void newRedisOperationsSessionRepository() { // tag::new-redisoperationssessionrepository[] LettuceConnectionFactory factory = new LettuceConnectionFactory(); - SessionRepository repository = new RedisOperationsSessionRepository( + SessionRepository repository = new RedisOperationsSessionRepository( factory); // end::new-redisoperationssessionrepository[] } @@ -120,7 +119,7 @@ public class IndexDocTests { @SuppressWarnings("unused") public void mapRepository() { // tag::new-mapsessionrepository[] - SessionRepository repository = new MapSessionRepository(); + SessionRepository repository = new MapSessionRepository(); // end::new-mapsessionrepository[] } @@ -136,7 +135,7 @@ public class IndexDocTests { // ... configure transactionManager ... - SessionRepository repository = + SessionRepository repository = new JdbcOperationsSessionRepository(jdbcTemplate, transactionManager); // end::new-jdbcoperationssessionrepository[] } diff --git a/docs/src/test/java/docs/security/RememberMeSecurityConfigurationTests.java b/docs/src/test/java/docs/security/RememberMeSecurityConfigurationTests.java index 2b45cace..fdd4b629 100644 --- a/docs/src/test/java/docs/security/RememberMeSecurityConfigurationTests.java +++ b/docs/src/test/java/docs/security/RememberMeSecurityConfigurationTests.java @@ -26,7 +26,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.web.http.SessionRepositoryFilter; import org.springframework.test.context.ContextConfiguration; @@ -48,7 +48,7 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv @ContextConfiguration(classes = RememberMeSecurityConfiguration.class) @WebAppConfiguration @SuppressWarnings("rawtypes") -public class RememberMeSecurityConfigurationTests { +public class RememberMeSecurityConfigurationTests { @Autowired WebApplicationContext context; @Autowired diff --git a/docs/src/test/java/docs/security/RememberMeSecurityConfigurationXmlTests.java b/docs/src/test/java/docs/security/RememberMeSecurityConfigurationXmlTests.java index 982bf05e..62bbc78a 100644 --- a/docs/src/test/java/docs/security/RememberMeSecurityConfigurationXmlTests.java +++ b/docs/src/test/java/docs/security/RememberMeSecurityConfigurationXmlTests.java @@ -26,7 +26,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.web.http.SessionRepositoryFilter; import org.springframework.test.context.ContextConfiguration; @@ -48,7 +48,7 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv @ContextConfiguration @WebAppConfiguration @SuppressWarnings("rawtypes") -public class RememberMeSecurityConfigurationXmlTests { +public class RememberMeSecurityConfigurationXmlTests { @Autowired WebApplicationContext context; @Autowired diff --git a/docs/src/test/java/docs/security/SecurityConfiguration.java b/docs/src/test/java/docs/security/SecurityConfiguration.java index 9548b37f..bb9e364e 100644 --- a/docs/src/test/java/docs/security/SecurityConfiguration.java +++ b/docs/src/test/java/docs/security/SecurityConfiguration.java @@ -21,8 +21,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; +import org.springframework.session.Session; import org.springframework.session.security.SpringSessionBackedSessionRegistry; /** @@ -33,7 +33,7 @@ import org.springframework.session.security.SpringSessionBackedSessionRegistry; public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Autowired - private FindByIndexNameSessionRepository sessionRepository; + private FindByIndexNameSessionRepository sessionRepository; @Override protected void configure(HttpSecurity http) throws Exception { diff --git a/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java b/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java index 9327f3d4..ce15b9f1 100644 --- a/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java +++ b/samples/boot/findbyusername/src/main/java/sample/mvc/IndexController.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -21,8 +21,8 @@ import java.util.Collection; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; +import org.springframework.session.Session; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; @@ -39,11 +39,11 @@ import org.springframework.web.bind.annotation.RequestMethod; public class IndexController { // tag::findbyusername[] @Autowired - FindByIndexNameSessionRepository sessions; + FindByIndexNameSessionRepository sessions; @RequestMapping("/") public String index(Principal principal, Model model) { - Collection usersSessions = this.sessions + Collection usersSessions = this.sessions .findByIndexNameAndIndexValue( FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, principal.getName()) diff --git a/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java b/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java index 8a28a553..abd602ef 100644 --- a/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java +++ b/samples/boot/websocket/src/main/java/sample/config/WebSocketConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -19,7 +19,7 @@ package sample.config; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.web.socket.config.annotation.AbstractSessionWebSocketMessageBrokerConfigurer; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; @@ -29,7 +29,7 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry; @EnableScheduling @EnableWebSocketMessageBroker public class WebSocketConfig - extends AbstractSessionWebSocketMessageBrokerConfigurer { // <1> + extends AbstractSessionWebSocketMessageBrokerConfigurer { // <1> protected void configureStompEndpoints(StompEndpointRegistry registry) { // <2> registry.addEndpoint("/messages").withSockJS(); diff --git a/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java b/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java index 6e0eeafe..bc59fe7d 100644 --- a/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java +++ b/samples/boot/websocket/src/main/java/sample/config/WebSocketHandlersConfig.java @@ -23,7 +23,7 @@ import sample.websocket.WebSocketDisconnectHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.SimpMessageSendingOperations; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; /** * These handlers are separated from WebSocketConfig because they are specific to this @@ -32,7 +32,7 @@ import org.springframework.session.ExpiringSession; * @author Rob Winch */ @Configuration -public class WebSocketHandlersConfig { +public class WebSocketHandlersConfig { @Bean public WebSocketConnectHandler webSocketConnectHandler( diff --git a/samples/javaconfig/rest/src/integration-test/java/rest/RestMockMvcTests.java b/samples/javaconfig/rest/src/integration-test/java/rest/RestMockMvcTests.java index ec9e1a19..5d6d7691 100644 --- a/samples/javaconfig/rest/src/integration-test/java/rest/RestMockMvcTests.java +++ b/samples/javaconfig/rest/src/integration-test/java/rest/RestMockMvcTests.java @@ -26,7 +26,7 @@ import sample.mvc.MvcConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.web.http.SessionRepositoryFilter; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -50,7 +50,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. public class RestMockMvcTests { @Autowired - SessionRepositoryFilter sessionRepositoryFilter; + SessionRepositoryFilter sessionRepositoryFilter; @Autowired WebApplicationContext context; diff --git a/samples/misc/hazelcast/src/main/java/sample/Initializer.java b/samples/misc/hazelcast/src/main/java/sample/Initializer.java index d52d813a..e117eb39 100644 --- a/samples/misc/hazelcast/src/main/java/sample/Initializer.java +++ b/samples/misc/hazelcast/src/main/java/sample/Initializer.java @@ -35,9 +35,9 @@ import com.hazelcast.config.SerializerConfig; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; -import org.springframework.session.ExpiringSession; import org.springframework.session.MapSession; import org.springframework.session.MapSessionRepository; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.web.http.SessionRepositoryFilter; @@ -62,11 +62,10 @@ public class Initializer implements ServletContextListener { cfg.addMapConfig(mc); this.instance = Hazelcast.newHazelcastInstance(cfg); - Map sessions = this.instance.getMap(sessionMapName); + Map sessions = this.instance.getMap(sessionMapName); - SessionRepository sessionRepository = new MapSessionRepository( - sessions); - SessionRepositoryFilter filter = new SessionRepositoryFilter<>( + SessionRepository sessionRepository = new MapSessionRepository(sessions); + SessionRepositoryFilter filter = new SessionRepositoryFilter<>( sessionRepository); Dynamic fr = sc.addFilter("springSessionFilter", filter); fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/redis/config/annotation/web/http/EnableRedisHttpSessionExpireSessionDestroyedTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/redis/config/annotation/web/http/EnableRedisHttpSessionExpireSessionDestroyedTests.java index 2c14037f..c57b7c9a 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/redis/config/annotation/web/http/EnableRedisHttpSessionExpireSessionDestroyedTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/redis/config/annotation/web/http/EnableRedisHttpSessionExpireSessionDestroyedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -32,7 +32,7 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.events.SessionExpiredEvent; import org.springframework.test.context.ContextConfiguration; @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @WebAppConfiguration -public class EnableRedisHttpSessionExpireSessionDestroyedTests { +public class EnableRedisHttpSessionExpireSessionDestroyedTests { @Autowired private SessionRepository repository; diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/redis/flushimmediately/RedisOperationsSessionRepositoryFlushImmediatelyITests.java b/spring-session/src/integration-test/java/org/springframework/session/data/redis/flushimmediately/RedisOperationsSessionRepositoryFlushImmediatelyITests.java index 5cd77056..4a87e0cf 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/redis/flushimmediately/RedisOperationsSessionRepositoryFlushImmediatelyITests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/redis/flushimmediately/RedisOperationsSessionRepositoryFlushImmediatelyITests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = RedisHttpSessionConfig.class) @WebAppConfiguration -public class RedisOperationsSessionRepositoryFlushImmediatelyITests { +public class RedisOperationsSessionRepositoryFlushImmediatelyITests { @Autowired private SessionRepository sessionRepository; diff --git a/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java b/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java index d42e43b6..f0dcf1d8 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -29,7 +29,6 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.Session; import org.springframework.session.SessionRepository; @@ -54,7 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @WebAppConfiguration -public class EnableHazelcastHttpSessionEventsTests { +public class EnableHazelcastHttpSessionEventsTests { private final static int MAX_INACTIVE_INTERVAL_IN_SECONDS = 1; @@ -119,7 +118,7 @@ public class EnableHazelcastHttpSessionEventsTests { assertThat(this.registry.getEvent(sessionToSave.getId())) .isInstanceOf(SessionExpiredEvent.class); - assertThat(this.repository.getSession(sessionToSave.getId())).isNull(); + assertThat(this.repository.getSession(sessionToSave.getId())).isNull(); } @Test diff --git a/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationXmlTests.java b/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationXmlTests.java index e128b30a..7719b75c 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationXmlTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/HazelcastHttpSessionConfigurationXmlTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -27,7 +27,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -42,12 +42,12 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Tommy Ludwig */ -public class HazelcastHttpSessionConfigurationXmlTests { +public class HazelcastHttpSessionConfigurationXmlTests { @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @WebAppConfiguration - public static class CustomXmlMapNameTest { + public static class CustomXmlMapNameTest { @Autowired private SessionRepository repository; @@ -84,7 +84,7 @@ public class HazelcastHttpSessionConfigurationXmlTests { + public static class CustomXmlMapNameAndIdleTest { @Autowired private SessionRepository repository; diff --git a/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java b/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java index c049e80b..fe66d03c 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -34,7 +34,6 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.MapSession; import org.springframework.session.Session; @@ -156,7 +155,7 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests { toSave.setLastAccessedTime(lastAccessedTime); this.repository.save(toSave); - ExpiringSession session = this.repository.getSession(toSave.getId()); + Session session = this.repository.getSession(toSave.getId()); assertThat(session).isNotNull(); assertThat(session.isExpired()).isFalse(); diff --git a/spring-session/src/main/java/org/springframework/session/ExpiringSession.java b/spring-session/src/main/java/org/springframework/session/ExpiringSession.java deleted file mode 100644 index ff408ed4..00000000 --- a/spring-session/src/main/java/org/springframework/session/ExpiringSession.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2014-2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.session; - -/** - * A {@link Session} that contains additional attributes that are useful for determining - * if a session is expired. - * - * @author Rob Winch - * @since 1.0 - */ -public interface ExpiringSession extends Session { - - /** - * Gets the time when this session was created in milliseconds since midnight of - * 1/1/1970 GMT. - * - * @return the time when this session was created in milliseconds since midnight of - * 1/1/1970 GMT. - */ - long getCreationTime(); - - /** - * Sets the last accessed time in milliseconds since midnight of 1/1/1970 GMT. - * - * @param lastAccessedTime the last accessed time in milliseconds since midnight of - * 1/1/1970 GMT - */ - void setLastAccessedTime(long lastAccessedTime); - - /** - * Gets the last time this {@link Session} was accessed expressed in milliseconds - * since midnight of 1/1/1970 GMT. - * - * @return the last time the client sent a request associated with the session - * expressed in milliseconds since midnight of 1/1/1970 GMT - */ - long getLastAccessedTime(); - - /** - * Sets the maximum inactive interval in seconds between requests before this session - * will be invalidated. A negative time indicates that the session will never timeout. - * - * @param interval the number of seconds that the {@link Session} should be kept alive - * between client requests. - */ - void setMaxInactiveIntervalInSeconds(int interval); - - /** - * Gets the maximum inactive interval in seconds between requests before this session - * will be invalidated. A negative time indicates that the session will never timeout. - * - * @return the maximum inactive interval in seconds between requests before this - * session will be invalidated. A negative time indicates that the session will never - * timeout. - */ - int getMaxInactiveIntervalInSeconds(); - - /** - * Returns true if the session is expired. - * - * @return true if the session is expired, else false. - */ - boolean isExpired(); - -} diff --git a/spring-session/src/main/java/org/springframework/session/MapSession.java b/spring-session/src/main/java/org/springframework/session/MapSession.java index 16278b0d..77008f0a 100644 --- a/spring-session/src/main/java/org/springframework/session/MapSession.java +++ b/spring-session/src/main/java/org/springframework/session/MapSession.java @@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit; * @author Rob Winch * @since 1.0 */ -public final class MapSession implements ExpiringSession, Serializable { +public final class MapSession implements Session, Serializable { /** * Default {@link #setMaxInactiveIntervalInSeconds(int)} (30 minutes). */ @@ -83,7 +83,7 @@ public final class MapSession implements ExpiringSession, Serializable { * @param session the {@link Session} to initialize this {@link Session} with. Cannot * be null. */ - public MapSession(ExpiringSession session) { + public MapSession(Session session) { if (session == null) { throw new IllegalArgumentException("session cannot be null"); } diff --git a/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java b/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java index 3dfa3367..67243a56 100644 --- a/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/MapSessionRepository.java @@ -36,14 +36,14 @@ import org.springframework.session.events.SessionExpiredEvent; * @author Rob Winch * @since 1.0 */ -public class MapSessionRepository implements SessionRepository { +public class MapSessionRepository implements SessionRepository { /** * If non-null, this value is used to override - * {@link ExpiringSession#setMaxInactiveIntervalInSeconds(int)}. + * {@link Session#setMaxInactiveIntervalInSeconds(int)}. */ private Integer defaultMaxInactiveInterval; - private final Map sessions; + private final Map sessions; /** * Creates an instance backed by a {@link java.util.concurrent.ConcurrentHashMap}. @@ -58,7 +58,7 @@ public class MapSessionRepository implements SessionRepository * * @param sessions the {@link java.util.Map} to use. Cannot be null. */ - public MapSessionRepository(Map sessions) { + public MapSessionRepository(Map sessions) { if (sessions == null) { throw new IllegalArgumentException("sessions cannot be null"); } @@ -67,7 +67,7 @@ public class MapSessionRepository implements SessionRepository /** * If non-null, this value is used to override - * {@link ExpiringSession#setMaxInactiveIntervalInSeconds(int)}. + * {@link Session#setMaxInactiveIntervalInSeconds(int)}. * @param defaultMaxInactiveInterval the number of seconds that the {@link Session} * should be kept alive between client requests. */ @@ -75,12 +75,12 @@ public class MapSessionRepository implements SessionRepository this.defaultMaxInactiveInterval = Integer.valueOf(defaultMaxInactiveInterval); } - public void save(ExpiringSession session) { + public void save(Session session) { this.sessions.put(session.getId(), new MapSession(session)); } - public ExpiringSession getSession(String id) { - ExpiringSession saved = this.sessions.get(id); + public Session getSession(String id) { + Session saved = this.sessions.get(id); if (saved == null) { return null; } @@ -95,8 +95,8 @@ public class MapSessionRepository implements SessionRepository this.sessions.remove(id); } - public ExpiringSession createSession() { - ExpiringSession result = new MapSession(); + public Session createSession() { + Session result = new MapSession(); if (this.defaultMaxInactiveInterval != null) { result.setMaxInactiveIntervalInSeconds(this.defaultMaxInactiveInterval); } diff --git a/spring-session/src/main/java/org/springframework/session/Session.java b/spring-session/src/main/java/org/springframework/session/Session.java index 0ab3f7af..34d45c88 100644 --- a/spring-session/src/main/java/org/springframework/session/Session.java +++ b/spring-session/src/main/java/org/springframework/session/Session.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -71,4 +71,57 @@ public interface Session { * @param attributeName the name of the attribute to remove */ void removeAttribute(String attributeName); + + /** + * Gets the time when this session was created in milliseconds since midnight of + * 1/1/1970 GMT. + * + * @return the time when this session was created in milliseconds since midnight of + * 1/1/1970 GMT. + */ + long getCreationTime(); + + /** + * Sets the last accessed time in milliseconds since midnight of 1/1/1970 GMT. + * + * @param lastAccessedTime the last accessed time in milliseconds since midnight of + * 1/1/1970 GMT + */ + void setLastAccessedTime(long lastAccessedTime); + + /** + * Gets the last time this {@link Session} was accessed expressed in milliseconds + * since midnight of 1/1/1970 GMT. + * + * @return the last time the client sent a request associated with the session + * expressed in milliseconds since midnight of 1/1/1970 GMT + */ + long getLastAccessedTime(); + + /** + * Sets the maximum inactive interval in seconds between requests before this session + * will be invalidated. A negative time indicates that the session will never timeout. + * + * @param interval the number of seconds that the {@link Session} should be kept alive + * between client requests. + */ + void setMaxInactiveIntervalInSeconds(int interval); + + /** + * Gets the maximum inactive interval in seconds between requests before this session + * will be invalidated. A negative time indicates that the session will never timeout. + * + * @return the maximum inactive interval in seconds between requests before this + * session will be invalidated. A negative time indicates that the session will never + * timeout. + */ + int getMaxInactiveIntervalInSeconds(); + + /** + * Returns true if the session is expired. + * + * @return true if the session is expired, else false. + */ + boolean isExpired(); + } diff --git a/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java b/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java index 388cb071..65df4784 100644 --- a/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java +++ b/spring-session/src/main/java/org/springframework/session/config/annotation/web/http/SpringHttpSessionConfiguration.java @@ -33,7 +33,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.events.SessionCreatedEvent; import org.springframework.session.events.SessionDestroyedEvent; @@ -122,7 +122,7 @@ public class SpringHttpSessionConfiguration implements ApplicationContextAware { } @Bean - public SessionRepositoryFilter springSessionRepositoryFilter( + public SessionRepositoryFilter springSessionRepositoryFilter( SessionRepository sessionRepository) { SessionRepositoryFilter sessionRepositoryFilter = new SessionRepositoryFilter<>( sessionRepository); diff --git a/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java index 9777fc03..2440bcb8 100644 --- a/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java @@ -39,7 +39,6 @@ import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.MapSession; import org.springframework.session.Session; @@ -259,20 +258,20 @@ public class RedisOperationsSessionRepository implements /** * The key in the Hash representing - * {@link org.springframework.session.ExpiringSession#getCreationTime()}. + * {@link org.springframework.session.Session#getCreationTime()}. */ static final String CREATION_TIME_ATTR = "creationTime"; /** * The key in the Hash representing - * {@link org.springframework.session.ExpiringSession#getMaxInactiveIntervalInSeconds()} + * {@link org.springframework.session.Session#getMaxInactiveIntervalInSeconds()} * . */ static final String MAX_INACTIVE_ATTR = "maxInactiveInterval"; /** * The key in the Hash representing - * {@link org.springframework.session.ExpiringSession#getLastAccessedTime()}. + * {@link org.springframework.session.Session#getLastAccessedTime()}. */ static final String LAST_ACCESSED_ATTR = "lastAccessedTime"; @@ -549,7 +548,7 @@ public class RedisOperationsSessionRepository implements public void handleCreated(Map loaded, String channel) { String id = channel.substring(channel.lastIndexOf(":") + 1); - ExpiringSession session = loadSession(id, loaded); + Session session = loadSession(id, loaded); publishEvent(new SessionCreatedEvent(this, session)); } @@ -667,7 +666,7 @@ public class RedisOperationsSessionRepository implements * @author Rob Winch * @since 1.0 */ - final class RedisSession implements ExpiringSession { + final class RedisSession implements Session { private final MapSession cached; private Long originalLastAccessTime; private Map delta = new HashMap<>(); diff --git a/spring-session/src/main/java/org/springframework/session/data/redis/RedisSessionExpirationPolicy.java b/spring-session/src/main/java/org/springframework/session/data/redis/RedisSessionExpirationPolicy.java index 706c034e..bc9c1217 100644 --- a/spring-session/src/main/java/org/springframework/session/data/redis/RedisSessionExpirationPolicy.java +++ b/spring-session/src/main/java/org/springframework/session/data/redis/RedisSessionExpirationPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -26,7 +26,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.data.redis.core.BoundSetOperations; import org.springframework.data.redis.core.RedisOperations; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.data.redis.RedisOperationsSessionRepository.RedisSession; /** @@ -61,14 +61,13 @@ final class RedisSessionExpirationPolicy { this.redisSession = redisSession; } - public void onDelete(ExpiringSession session) { + public void onDelete(Session session) { long toExpire = roundUpToNextMinute(expiresInMillis(session)); String expireKey = getExpirationKey(toExpire); this.redis.boundSetOps(expireKey).remove(session.getId()); } - public void onExpirationUpdated(Long originalExpirationTimeInMilli, - ExpiringSession session) { + public void onExpirationUpdated(Long originalExpirationTimeInMilli, Session session) { String keyToExpire = "expires:" + session.getId(); long toExpire = roundUpToNextMinute(expiresInMillis(session)); @@ -147,7 +146,7 @@ final class RedisSessionExpirationPolicy { this.redis.hasKey(key); } - static long expiresInMillis(ExpiringSession session) { + static long expiresInMillis(Session session) { int maxInactiveInSeconds = session.getMaxInactiveIntervalInSeconds(); long lastAccessedTimeInMillis = session.getLastAccessedTime(); return lastAccessedTimeInMillis + TimeUnit.SECONDS.toMillis(maxInactiveInSeconds); diff --git a/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java b/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java index 861e74b0..fe5b21c9 100644 --- a/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/hazelcast/HazelcastSessionRepository.java @@ -37,7 +37,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.MapSession; import org.springframework.session.Session; @@ -267,7 +266,7 @@ public class HazelcastSessionRepository implements * * @author Aleksandar Stojsavljevic */ - final class HazelcastSession implements ExpiringSession { + final class HazelcastSession implements Session { private final MapSession delegate; private boolean changed; diff --git a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java index 8c28ba32..6ce2ed4f 100644 --- a/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java @@ -46,7 +46,6 @@ import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.support.lob.DefaultLobHandler; import org.springframework.jdbc.support.lob.LobHandler; import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.MapSession; import org.springframework.session.Session; @@ -185,8 +184,7 @@ public class JdbcOperationsSessionRepository implements private final TransactionOperations transactionOperations; - private final ResultSetExtractor> extractor = - new ExpiringSessionResultSetExtractor(); + private final ResultSetExtractor> extractor = new SessionResultSetExtractor(); /** * The name of database table used by Spring Session to store sessions. @@ -460,8 +458,8 @@ public class JdbcOperationsSessionRepository implements } public JdbcSession getSession(final String id) { - final ExpiringSession session = this.transactionOperations.execute(status -> { - List sessions = JdbcOperationsSessionRepository.this.jdbcOperations.query( + final Session session = this.transactionOperations.execute(status -> { + List sessions = JdbcOperationsSessionRepository.this.jdbcOperations.query( JdbcOperationsSessionRepository.this.getSessionQuery, ps -> ps.setString(1, id), JdbcOperationsSessionRepository.this.extractor @@ -500,7 +498,7 @@ public class JdbcOperationsSessionRepository implements return Collections.emptyMap(); } - List sessions = this.transactionOperations.execute(status -> + List sessions = this.transactionOperations.execute(status -> JdbcOperationsSessionRepository.this.jdbcOperations.query( JdbcOperationsSessionRepository.this.listSessionsByPrincipalNameQuery, ps -> ps.setString(1, indexValue), @@ -509,7 +507,7 @@ public class JdbcOperationsSessionRepository implements Map sessionMap = new HashMap<>( sessions.size()); - for (ExpiringSession session : sessions) { + for (Session session : sessions) { sessionMap.put(session.getId(), new JdbcSession(session)); } @@ -588,13 +586,13 @@ public class JdbcOperationsSessionRepository implements } /** - * The {@link ExpiringSession} to use for {@link JdbcOperationsSessionRepository}. + * The {@link Session} to use for {@link JdbcOperationsSessionRepository}. * * @author Vedran Pavic */ - final class JdbcSession implements ExpiringSession { + final class JdbcSession implements Session { - private final ExpiringSession delegate; + private final Session delegate; private boolean isNew; @@ -607,8 +605,8 @@ public class JdbcOperationsSessionRepository implements this.isNew = true; } - JdbcSession(ExpiringSession delegate) { - Assert.notNull(delegate, "ExpiringSession cannot be null"); + JdbcSession(Session delegate) { + Assert.notNull(delegate, "Session cannot be null"); this.delegate = delegate; } @@ -713,11 +711,10 @@ public class JdbcOperationsSessionRepository implements } - private class ExpiringSessionResultSetExtractor - implements ResultSetExtractor> { + private class SessionResultSetExtractor implements ResultSetExtractor> { - public List extractData(ResultSet rs) throws SQLException, DataAccessException { - List sessions = new ArrayList<>(); + public List extractData(ResultSet rs) throws SQLException, DataAccessException { + List sessions = new ArrayList<>(); while (rs.next()) { String id = rs.getString("SESSION_ID"); MapSession session; @@ -739,7 +736,7 @@ public class JdbcOperationsSessionRepository implements return sessions; } - private ExpiringSession getLast(List sessions) { + private Session getLast(List sessions) { return sessions.get(sessions.size() - 1); } diff --git a/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionInformation.java b/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionInformation.java index ea3fc57c..88bd51d8 100644 --- a/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionInformation.java +++ b/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionInformation.java @@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.session.SessionInformation; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.Session; import org.springframework.session.SessionRepository; @@ -32,12 +31,12 @@ import org.springframework.session.SessionRepository; * Ensures that calling {@link #expireNow()} propagates to Spring Session, since this * session information contains only derived data and is not the authoritative source. * - * @param the {@link ExpiringSession} type. + * @param the {@link Session} type. * @author Joris Kuipers * @author Vedran Pavic * @since 1.3 */ -class SpringSessionBackedSessionInformation +class SpringSessionBackedSessionInformation extends SessionInformation { static final String EXPIRED_ATTR = SpringSessionBackedSessionInformation.class diff --git a/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java b/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java index 5b07eaa6..ad9f6cd7 100644 --- a/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java +++ b/spring-session/src/main/java/org/springframework/session/security/SpringSessionBackedSessionRegistry.java @@ -24,8 +24,8 @@ import java.util.List; import org.springframework.security.core.session.SessionInformation; import org.springframework.security.core.session.SessionRegistry; import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; +import org.springframework.session.Session; import org.springframework.util.Assert; /** @@ -39,12 +39,12 @@ import org.springframework.util.Assert; *

* Does not support {@link #getAllPrincipals()}, since that information is not available. * - * @param the {@link ExpiringSession} type. + * @param the {@link Session} type. * @author Joris Kuipers * @author Vedran Pavic * @since 1.3 */ -public class SpringSessionBackedSessionRegistry +public class SpringSessionBackedSessionRegistry implements SessionRegistry { private final FindByIndexNameSessionRepository sessionRepository; diff --git a/spring-session/src/main/java/org/springframework/session/web/http/ExpiringSessionHttpSession.java b/spring-session/src/main/java/org/springframework/session/web/http/HttpSessionAdapter.java similarity index 90% rename from spring-session/src/main/java/org/springframework/session/web/http/ExpiringSessionHttpSession.java rename to spring-session/src/main/java/org/springframework/session/web/http/HttpSessionAdapter.java index 36b74f66..08a46424 100644 --- a/spring-session/src/main/java/org/springframework/session/web/http/ExpiringSessionHttpSession.java +++ b/spring-session/src/main/java/org/springframework/session/web/http/HttpSessionAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -25,23 +25,23 @@ import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionContext; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; /** - * Adapts Spring Session's {@link ExpiringSession} to an {@link HttpSession}. + * Adapts Spring Session's {@link Session} to an {@link HttpSession}. * - * @param the {@link ExpiringSession} type + * @param the {@link Session} type * @author Rob Winch * @since 1.1 */ @SuppressWarnings("deprecation") -class ExpiringSessionHttpSession implements HttpSession { +class HttpSessionAdapter implements HttpSession { private S session; private final ServletContext servletContext; private boolean invalidated; private boolean old; - ExpiringSessionHttpSession(S session, ServletContext servletContext) { + HttpSessionAdapter(S session, ServletContext servletContext) { this.session = session; this.servletContext = servletContext; } diff --git a/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java b/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java index f3462f12..238de606 100644 --- a/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java +++ b/spring-session/src/main/java/org/springframework/session/web/http/SessionEventHttpSessionListenerAdapter.java @@ -24,7 +24,7 @@ import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; import org.springframework.context.ApplicationListener; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.events.AbstractSessionEvent; import org.springframework.session.events.SessionCreatedEvent; import org.springframework.session.events.SessionDestroyedEvent; @@ -73,8 +73,8 @@ public class SessionEventHttpSessionListenerAdapter } private HttpSessionEvent createHttpSessionEvent(AbstractSessionEvent event) { - ExpiringSession session = event.getSession(); - HttpSession httpSession = new ExpiringSessionHttpSession<>(session, + Session session = event.getSession(); + HttpSession httpSession = new HttpSessionAdapter<>(session, this.context); HttpSessionEvent httpSessionEvent = new HttpSessionEvent(httpSession); return httpSessionEvent; diff --git a/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java b/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java index 6643a1fc..afb48cb8 100644 --- a/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java +++ b/spring-session/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java @@ -33,7 +33,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.core.annotation.Order; -import org.springframework.session.ExpiringSession; import org.springframework.session.Session; import org.springframework.session.SessionRepository; @@ -56,7 +55,7 @@ import org.springframework.session.SessionRepository; *

  • The session id is looked up using * {@link HttpSessionStrategy#getRequestedSessionId(javax.servlet.http.HttpServletRequest)} * . The default is to look in a cookie named SESSION.
  • - *
  • The session id of newly created {@link org.springframework.session.ExpiringSession} + *
  • The session id of newly created {@link org.springframework.session.Session} * is sent to the client using *
  • The client is notified that the session id is no longer valid with * {@link HttpSessionStrategy#onInvalidateSession(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)} @@ -69,12 +68,12 @@ import org.springframework.session.SessionRepository; * persisted properly. *

    * - * @param the {@link ExpiringSession} type. + * @param the {@link Session} type. * @since 1.0 * @author Rob Winch */ @Order(SessionRepositoryFilter.DEFAULT_ORDER) -public class SessionRepositoryFilter +public class SessionRepositoryFilter extends OncePerRequestFilter { private static final String SESSION_LOGGER_NAME = SessionRepositoryFilter.class .getName().concat(".SESSION_LOGGER"); @@ -402,7 +401,7 @@ public class SessionRepositoryFilter * @author Rob Winch * @since 1.0 */ - private final class HttpSessionWrapper extends ExpiringSessionHttpSession { + private final class HttpSessionWrapper extends HttpSessionAdapter { HttpSessionWrapper(S session, ServletContext servletContext) { super(session, servletContext); diff --git a/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java b/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java index f0a2524a..6a46e50d 100644 --- a/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java +++ b/spring-session/src/main/java/org/springframework/session/web/socket/config/annotation/AbstractSessionWebSocketMessageBrokerConfigurer.java @@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.messaging.simp.config.ChannelRegistration; -import org.springframework.session.ExpiringSession; import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.session.web.socket.handler.WebSocketConnectHandlerDecoratorFactory; @@ -55,7 +54,7 @@ import org.springframework.web.util.UrlPathHelper; * {@literal @Configuration} * {@literal @EnableScheduling} * {@literal @EnableWebSocketMessageBroker} - * {@literal public class WebSocketConfig extends AbstractSessionWebSocketMessageBrokerConfigurer} { + * {@literal public class WebSocketConfig extends AbstractSessionWebSocketMessageBrokerConfigurer} { * * {@literal @Override} * protected void configureStompEndpoints(StompEndpointRegistry registry) { @@ -71,11 +70,11 @@ import org.springframework.web.util.UrlPathHelper; * } * * - * @param the type of ExpiringSession + * @param the type of Session * @author Rob Winch * @since 1.0 */ -public abstract class AbstractSessionWebSocketMessageBrokerConfigurer +public abstract class AbstractSessionWebSocketMessageBrokerConfigurer extends AbstractWebSocketMessageBrokerConfigurer { @Autowired diff --git a/spring-session/src/main/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptor.java b/spring-session/src/main/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptor.java index 9da32b0f..bcf7c129 100644 --- a/spring-session/src/main/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptor.java +++ b/spring-session/src/main/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -31,7 +31,6 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.ChannelInterceptorAdapter; -import org.springframework.session.ExpiringSession; import org.springframework.session.Session; import org.springframework.session.SessionRepository; import org.springframework.util.Assert; @@ -41,12 +40,12 @@ import org.springframework.web.socket.server.HandshakeInterceptor; /** *

    * Acts as a {@link ChannelInterceptor} and a {@link HandshakeInterceptor} to ensure the - * {@link ExpiringSession#getLastAccessedTime()} is up to date. + * {@link Session#getLastAccessedTime()} is up to date. *

    *
      *
    • Associates the {@link Session#getId()} with the WebSocket Session attributes when * the handshake is performed. This is later used when intercepting messages to ensure the - * {@link ExpiringSession#getLastAccessedTime()} is updated.
    • + * {@link Session#getLastAccessedTime()} is updated. *
    • Intercepts {@link Message}'s that are have {@link SimpMessageType} that corresponds * to {@link #setMatchingMessageTypes(Set)} and updates the last accessed time of the * {@link Session}. If the {@link Session} is expired, the {@link Message} is prevented @@ -58,11 +57,11 @@ import org.springframework.web.socket.server.HandshakeInterceptor; * {@link ChannelInterceptor} and a {@link HandshakeInterceptor} . *

      * - * @param the {@link ExpiringSession} type + * @param the {@link Session} type * @author Rob Winch * @since 1.0 */ -public final class SessionRepositoryMessageInterceptor +public final class SessionRepositoryMessageInterceptor extends ChannelInterceptorAdapter implements HandshakeInterceptor { private static final String SPRING_SESSION_ID_ATTR_NAME = "SPRING.SESSION.ID"; @@ -88,7 +87,7 @@ public final class SessionRepositoryMessageInterceptor * Sets the {@link SimpMessageType} to match on. If the {@link Message} matches, then * {@link #preSend(Message, MessageChannel)} ensures the {@link Session} is not - * expired and updates the {@link ExpiringSession#getLastAccessedTime()} + * expired and updates the {@link Session#getLastAccessedTime()} *

      * *

      diff --git a/spring-session/src/test/java/org/springframework/session/MapSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/MapSessionRepositoryTests.java index 0c3bffdd..c9ffff91 100644 --- a/spring-session/src/test/java/org/springframework/session/MapSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/MapSessionRepositoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -46,7 +46,7 @@ public class MapSessionRepositoryTests { @Test public void createSessionDefaultExpiration() { - ExpiringSession session = this.repository.createSession(); + Session session = this.repository.createSession(); assertThat(session).isInstanceOf(MapSession.class); assertThat(session.getMaxInactiveIntervalInSeconds()) @@ -59,7 +59,7 @@ public class MapSessionRepositoryTests { + 10; this.repository.setDefaultMaxInactiveInterval(expectedMaxInterval); - ExpiringSession session = this.repository.createSession(); + Session session = this.repository.createSession(); assertThat(session.getMaxInactiveIntervalInSeconds()) .isEqualTo(expectedMaxInterval); diff --git a/spring-session/src/test/java/org/springframework/session/MapSessionTests.java b/spring-session/src/test/java/org/springframework/session/MapSessionTests.java index 3088495a..361d22f2 100644 --- a/spring-session/src/test/java/org/springframework/session/MapSessionTests.java +++ b/spring-session/src/test/java/org/springframework/session/MapSessionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-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. @@ -35,7 +35,7 @@ public class MapSessionTests { @Test(expected = IllegalArgumentException.class) public void constructorNullSession() { - new MapSession((ExpiringSession) null); + new MapSession((Session) null); } /** @@ -85,7 +85,7 @@ public class MapSessionTests { assertThat(this.session.isExpired(now)).isTrue(); } - static class CustomSession implements ExpiringSession { + static class CustomSession implements Session { public long getCreationTime() { return 0; diff --git a/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomCookieSerializerTests.java b/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomCookieSerializerTests.java index d69ae9c4..1abbdb54 100644 --- a/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomCookieSerializerTests.java +++ b/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomCookieSerializerTests.java @@ -34,8 +34,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.mock.web.MockFilterChain; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.session.ExpiringSession; import org.springframework.session.MapSessionRepository; +import org.springframework.session.Session; import org.springframework.session.web.http.CookieSerializer; import org.springframework.session.web.http.CookieSerializer.CookieValue; import org.springframework.session.web.http.SessionRepositoryFilter; @@ -65,7 +65,7 @@ public class EnableSpringHttpSessionCustomCookieSerializerTests { MockFilterChain chain; @Autowired - SessionRepositoryFilter sessionRepositoryFilter; + SessionRepositoryFilter sessionRepositoryFilter; @Autowired CookieSerializer cookieSerializer; diff --git a/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomMultiHttpSessionStrategyTests.java b/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomMultiHttpSessionStrategyTests.java index 32202748..2b582601 100644 --- a/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomMultiHttpSessionStrategyTests.java +++ b/spring-session/src/test/java/org/springframework/session/config/annotation/web/http/EnableSpringHttpSessionCustomMultiHttpSessionStrategyTests.java @@ -29,8 +29,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.mock.web.MockFilterChain; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.session.ExpiringSession; import org.springframework.session.MapSessionRepository; +import org.springframework.session.Session; import org.springframework.session.web.http.MultiHttpSessionStrategy; import org.springframework.session.web.http.SessionRepositoryFilter; import org.springframework.test.context.ContextConfiguration; @@ -58,7 +58,7 @@ public class EnableSpringHttpSessionCustomMultiHttpSessionStrategyTests { MockFilterChain chain; @Autowired - SessionRepositoryFilter sessionRepositoryFilter; + SessionRepositoryFilter sessionRepositoryFilter; @Autowired MultiHttpSessionStrategy strategy; diff --git a/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java index 7ce71ec3..141df6ca 100644 --- a/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java @@ -47,9 +47,9 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextImpl; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.MapSession; +import org.springframework.session.Session; import org.springframework.session.data.redis.RedisOperationsSessionRepository.PrincipalNameResolver; import org.springframework.session.data.redis.RedisOperationsSessionRepository.RedisSession; import org.springframework.session.events.AbstractSessionEvent; @@ -130,7 +130,7 @@ public class RedisOperationsSessionRepositoryTests { @Test public void createSessionDefaultMaxInactiveInterval() throws Exception { - ExpiringSession session = this.redisRepository.createSession(); + Session session = this.redisRepository.createSession(); assertThat(session.getMaxInactiveIntervalInSeconds()) .isEqualTo(new MapSession().getMaxInactiveIntervalInSeconds()); } @@ -139,7 +139,7 @@ public class RedisOperationsSessionRepositoryTests { public void createSessionCustomMaxInactiveInterval() throws Exception { int interval = 1; this.redisRepository.setDefaultMaxInactiveInterval(interval); - ExpiringSession session = this.redisRepository.createSession(); + Session session = this.redisRepository.createSession(); assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(interval); } diff --git a/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java b/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java index aa846264..b2d51d1b 100644 --- a/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java +++ b/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java @@ -30,13 +30,12 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextImpl; import org.springframework.security.core.session.SessionInformation; import org.springframework.security.core.userdetails.User; -import org.springframework.session.ExpiringSession; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.MapSession; +import org.springframework.session.Session; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.mock; @@ -56,19 +55,19 @@ public class SpringSessionBackedSessionRegistryTest { private static final String USER_NAME = "userName"; private static final User PRINCIPAL = new User(USER_NAME, "password", - Collections.emptyList()); + Collections.emptyList()); private static final Date NOW = new Date(); @Mock - private FindByIndexNameSessionRepository sessionRepository; + private FindByIndexNameSessionRepository sessionRepository; @InjectMocks - private SpringSessionBackedSessionRegistry sessionRegistry; + private SpringSessionBackedSessionRegistry sessionRegistry; @Test public void sessionInformationForExistingSession() { - ExpiringSession session = createSession(SESSION_ID, USER_NAME, NOW.getTime()); + Session session = createSession(SESSION_ID, USER_NAME, NOW.getTime()); when(this.sessionRepository.getSession(SESSION_ID)).thenReturn(session); SessionInformation sessionInfo = this.sessionRegistry @@ -82,7 +81,7 @@ public class SpringSessionBackedSessionRegistryTest { @Test public void sessionInformationForExpiredSession() { - ExpiringSession session = createSession(SESSION_ID, USER_NAME, NOW.getTime()); + Session session = createSession(SESSION_ID, USER_NAME, NOW.getTime()); session.setAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR, Boolean.TRUE); when(this.sessionRepository.getSession(SESSION_ID)).thenReturn(session); @@ -126,7 +125,7 @@ public class SpringSessionBackedSessionRegistryTest { @Test public void expireNow() { - ExpiringSession session = createSession(SESSION_ID, USER_NAME, NOW.getTime()); + Session session = createSession(SESSION_ID, USER_NAME, NOW.getTime()); when(this.sessionRepository.getSession(SESSION_ID)).thenReturn(session); SessionInformation sessionInfo = this.sessionRegistry @@ -136,16 +135,14 @@ public class SpringSessionBackedSessionRegistryTest { sessionInfo.expireNow(); assertThat(sessionInfo.isExpired()).isTrue(); - ArgumentCaptor captor = ArgumentCaptor - .forClass(ExpiringSession.class); + ArgumentCaptor captor = ArgumentCaptor.forClass(Session.class); verify(this.sessionRepository).save(captor.capture()); assertThat(captor.getValue().getAttribute( SpringSessionBackedSessionInformation.EXPIRED_ATTR)) .isEqualTo(Boolean.TRUE); } - private ExpiringSession createSession(String sessionId, String userName, - Long lastAccessed) { + private Session createSession(String sessionId, String userName, Long lastAccessed) { MapSession session = new MapSession(sessionId); session.setLastAccessedTime(lastAccessed); Authentication authentication = mock(Authentication.class); @@ -157,11 +154,11 @@ public class SpringSessionBackedSessionRegistryTest { } private void setUpSessions() { - ExpiringSession session1 = createSession(SESSION_ID, USER_NAME, NOW.getTime()); + Session session1 = createSession(SESSION_ID, USER_NAME, NOW.getTime()); session1.setAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR, Boolean.TRUE); - ExpiringSession session2 = createSession(SESSION_ID2, USER_NAME, NOW.getTime()); - Map sessions = new LinkedHashMap<>(); + Session session2 = createSession(SESSION_ID2, USER_NAME, NOW.getTime()); + Map sessions = new LinkedHashMap<>(); sessions.put(session1.getId(), session1); sessions.put(session2.getId(), session2); when(this.sessionRepository.findByIndexNameAndIndexValue( diff --git a/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java b/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java index 06ffec4e..461cc82b 100644 --- a/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java +++ b/spring-session/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java @@ -49,7 +49,6 @@ import org.springframework.mock.web.MockFilterChain; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; -import org.springframework.session.ExpiringSession; import org.springframework.session.MapSession; import org.springframework.session.MapSessionRepository; import org.springframework.session.Session; @@ -74,11 +73,11 @@ public class SessionRepositoryFilterTests { @Mock private HttpSessionStrategy strategy; - private Map sessions; + private Map sessions; - private SessionRepository sessionRepository; + private SessionRepository sessionRepository; - private SessionRepositoryFilter filter; + private SessionRepositoryFilter filter; private MockHttpServletRequest request; @@ -422,7 +421,7 @@ public class SessionRepositoryFilterTests { public void doFilterSetsCookieIfChanged() throws Exception { this.sessionRepository = new MapSessionRepository() { @Override - public ExpiringSession getSession(String id) { + public Session getSession(String id) { return createSession(); } }; @@ -1256,8 +1255,7 @@ public class SessionRepositoryFilterTests { @SuppressWarnings("unchecked") public void doFilterRequestSessionNoRequestSessionNoSessionRepositoryInteractions() throws Exception { - SessionRepository sessionRepository = spy( - new MapSessionRepository()); + SessionRepository sessionRepository = spy(new MapSessionRepository()); this.filter = new SessionRepositoryFilter<>(sessionRepository); @@ -1284,8 +1282,7 @@ public class SessionRepositoryFilterTests { @Test public void doFilterLazySessionCreation() throws Exception { - SessionRepository sessionRepository = spy( - new MapSessionRepository()); + SessionRepository sessionRepository = spy(new MapSessionRepository()); this.filter = new SessionRepositoryFilter<>(sessionRepository); @@ -1301,10 +1298,9 @@ public class SessionRepositoryFilterTests { @Test public void doFilterLazySessionUpdates() throws Exception { - ExpiringSession session = this.sessionRepository.createSession(); + Session session = this.sessionRepository.createSession(); this.sessionRepository.save(session); - SessionRepository sessionRepository = spy( - this.sessionRepository); + SessionRepository sessionRepository = spy(this.sessionRepository); setSessionCookie(session.getId()); this.filter = new SessionRepositoryFilter<>(sessionRepository); diff --git a/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java b/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java index 068df07b..cdf6ff64 100644 --- a/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java +++ b/spring-session/src/test/java/org/springframework/session/web/socket/server/SessionRepositoryMessageInterceptorTests.java @@ -38,7 +38,7 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; import org.springframework.messaging.support.MessageBuilder; import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.session.ExpiringSession; +import org.springframework.session.Session; import org.springframework.session.SessionRepository; import static org.assertj.core.api.Assertions.assertThat; @@ -53,17 +53,17 @@ import static org.mockito.Mockito.verifyZeroInteractions; @RunWith(MockitoJUnitRunner.class) public class SessionRepositoryMessageInterceptorTests { @Mock - SessionRepository sessionRepository; + SessionRepository sessionRepository; @Mock MessageChannel channel; @Mock - ExpiringSession session; + Session session; Message createMessage; SimpMessageHeaderAccessor headers; - SessionRepositoryMessageInterceptor interceptor; + SessionRepositoryMessageInterceptor interceptor; @Before public void setup() { @@ -202,7 +202,7 @@ public class SessionRepositoryMessageInterceptorTests { this.interceptor.preSend(createMessage(), this.channel); - verify(this.sessionRepository, times(0)).save(any(ExpiringSession.class)); + verify(this.sessionRepository, times(0)).save(any(Session.class)); } @Test