diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisOperationsSessionRepository.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisOperationsSessionRepository.java deleted file mode 100644 index ee7e6446..00000000 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/ReactiveRedisOperationsSessionRepository.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2014-2019 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 - * - * https://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.data.redis; - -import org.springframework.data.redis.core.ReactiveRedisOperations; -import org.springframework.session.ReactiveSessionRepository; -import org.springframework.util.Assert; - -/** - * This {@link ReactiveSessionRepository} implementation is kept in order to support - * migration to {@link ReactiveRedisSessionRepository} in a backwards compatible manner. - * - * @author Vedran Pavic - * @since 2.0.0 - * @deprecated since 2.2.0 in favor of {@link ReactiveRedisSessionRepository} - */ -@Deprecated -public class ReactiveRedisOperationsSessionRepository extends ReactiveRedisSessionRepository { - - /** - * Create a new {@link ReactiveRedisOperationsSessionRepository} instance. - * @param sessionRedisOperations the {@link ReactiveRedisOperations} to use for - * managing sessions - * @see ReactiveRedisSessionRepository#ReactiveRedisSessionRepository(ReactiveRedisOperations) - */ - public ReactiveRedisOperationsSessionRepository(ReactiveRedisOperations sessionRedisOperations) { - super(sessionRedisOperations); - } - - /** - * Sets the redis flush mode. Default flush mode is {@link RedisFlushMode#ON_SAVE}. - * @param redisFlushMode the new redis flush mode - * @deprecated since 2.2.0 as support {@code IMMEDIATE} is removed - */ - @Deprecated - public void setRedisFlushMode(RedisFlushMode redisFlushMode) { - Assert.notNull(redisFlushMode, "redisFlushMode cannot be null"); - } - -} diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisFlushMode.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisFlushMode.java deleted file mode 100644 index 50a0addd..00000000 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisFlushMode.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2014-2019 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 - * - * https://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.data.redis; - -import org.springframework.session.FlushMode; -import org.springframework.session.SessionRepository; - -/** - * Specifies when to write to the backing Redis instance. - * - * @author Rob Winch - * @since 1.1 - * @deprecated since 2.2.0 in favor of {@link FlushMode} - */ -@Deprecated -public enum RedisFlushMode { - - /** - * Only writes to Redis when - * {@link SessionRepository#save(org.springframework.session.Session)} is invoked. In - * a web environment this is typically done as soon as the HTTP response is committed. - */ - ON_SAVE(FlushMode.ON_SAVE), - - /** - * Writes to Redis as soon as possible. For example - * {@link SessionRepository#createSession()} will write the session to Redis. Another - * example is that setting an attribute on the session will also write to Redis - * immediately. - */ - IMMEDIATE(FlushMode.IMMEDIATE); - - private final FlushMode flushMode; - - RedisFlushMode(FlushMode flushMode) { - this.flushMode = flushMode; - } - - public FlushMode getFlushMode() { - return this.flushMode; - } - -} diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java deleted file mode 100644 index 554a01c3..00000000 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisOperationsSessionRepository.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2014-2019 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 - * - * https://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.data.redis; - -import org.springframework.data.redis.core.RedisOperations; -import org.springframework.session.FlushMode; -import org.springframework.session.SessionRepository; -import org.springframework.util.Assert; - -/** - * This {@link SessionRepository} implementation is kept in order to support migration to - * {@link RedisIndexedSessionRepository} in a backwards compatible manner. - * - * @author Rob Winch - * @author Vedran Pavic - * @since 1.0 - * @deprecated since 2.2.0 in favor of {@link RedisIndexedSessionRepository} - */ -@Deprecated -public class RedisOperationsSessionRepository extends RedisIndexedSessionRepository { - - /** - * Creates a new instance. For an example, refer to the class level javadoc. - * @param sessionRedisOperations the {@link RedisOperations} to use for managing the - * sessions. Cannot be null. - * @see RedisIndexedSessionRepository#RedisIndexedSessionRepository(RedisOperations) - */ - public RedisOperationsSessionRepository(RedisOperations sessionRedisOperations) { - super(sessionRedisOperations); - } - - /** - * Sets the redis flush mode. Default flush mode is {@link RedisFlushMode#ON_SAVE}. - * @param redisFlushMode the new redis flush mode - * @deprecated since 2.2.0 in favor of {@link #setFlushMode(FlushMode)} - */ - @Deprecated - public void setRedisFlushMode(RedisFlushMode redisFlushMode) { - Assert.notNull(redisFlushMode, "redisFlushMode cannot be null"); - setFlushMode(redisFlushMode.getFlushMode()); - } - -} diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisSessionRepository.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisSessionRepository.java index 75dde726..4ef4b229 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisSessionRepository.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisSessionRepository.java @@ -76,17 +76,6 @@ public class RedisSessionRepository implements SessionRepository - * Setting the value to {@code IMMEDIATE} will ensure that the any updates to the - * Session are immediately written to the Redis instance. - * @return the {@link RedisFlushMode} to use - * @since 1.1 - * @deprecated since 2.2.0 in favor of {@link #flushMode()} - */ - @Deprecated - RedisFlushMode redisFlushMode() default RedisFlushMode.ON_SAVE; - /** * Flush mode for the Redis sessions. The default is {@code ON_SAVE} which only * updates the backing Redis when {@link SessionRepository#save(Session)} is invoked. diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java index 814f4eec..923a382d 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.java @@ -40,7 +40,6 @@ import org.springframework.session.MapSession; import org.springframework.session.SaveMode; import org.springframework.session.config.SessionRepositoryCustomizer; import org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration; -import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.session.data.redis.RedisSessionRepository; import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory; import org.springframework.session.web.http.SessionRepositoryFilter; @@ -104,12 +103,6 @@ public class RedisHttpSessionConfiguration extends SpringHttpSessionConfiguratio this.redisNamespace = namespace; } - @Deprecated - public void setRedisFlushMode(RedisFlushMode redisFlushMode) { - Assert.notNull(redisFlushMode, "redisFlushMode cannot be null"); - setFlushMode(redisFlushMode.getFlushMode()); - } - public void setFlushMode(FlushMode flushMode) { Assert.notNull(flushMode, "flushMode cannot be null"); this.flushMode = flushMode; @@ -153,7 +146,6 @@ public class RedisHttpSessionConfiguration extends SpringHttpSessionConfiguratio } @Override - @SuppressWarnings("deprecation") public void setImportMetadata(AnnotationMetadata importMetadata) { Map attributeMap = importMetadata .getAnnotationAttributes(EnableRedisHttpSession.class.getName()); @@ -163,12 +155,7 @@ public class RedisHttpSessionConfiguration extends SpringHttpSessionConfiguratio if (StringUtils.hasText(redisNamespaceValue)) { this.redisNamespace = this.embeddedValueResolver.resolveStringValue(redisNamespaceValue); } - FlushMode flushMode = attributes.getEnum("flushMode"); - RedisFlushMode redisFlushMode = attributes.getEnum("redisFlushMode"); - if (flushMode == FlushMode.ON_SAVE && redisFlushMode != RedisFlushMode.ON_SAVE) { - flushMode = redisFlushMode.getFlushMode(); - } - this.flushMode = flushMode; + this.flushMode = attributes.getEnum("flushMode"); this.saveMode = attributes.getEnum("saveMode"); } diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfiguration.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfiguration.java index ad85e01c..67614d50 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfiguration.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfiguration.java @@ -57,7 +57,6 @@ import org.springframework.session.SaveMode; import org.springframework.session.Session; import org.springframework.session.config.SessionRepositoryCustomizer; import org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration; -import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.session.data.redis.RedisIndexedSessionRepository; import org.springframework.session.data.redis.config.ConfigureNotifyKeyspaceEventsAction; import org.springframework.session.data.redis.config.ConfigureRedisAction; @@ -168,12 +167,6 @@ public class RedisIndexedHttpSessionConfiguration extends SpringHttpSessionConfi this.redisNamespace = namespace; } - @Deprecated - public void setRedisFlushMode(RedisFlushMode redisFlushMode) { - Assert.notNull(redisFlushMode, "redisFlushMode cannot be null"); - setFlushMode(redisFlushMode.getFlushMode()); - } - public void setFlushMode(FlushMode flushMode) { Assert.notNull(flushMode, "flushMode cannot be null"); this.flushMode = flushMode; @@ -253,7 +246,6 @@ public class RedisIndexedHttpSessionConfiguration extends SpringHttpSessionConfi } @Override - @SuppressWarnings("deprecation") public void setImportMetadata(AnnotationMetadata importMetadata) { Map attributeMap = importMetadata .getAnnotationAttributes(EnableRedisHttpSession.class.getName()); @@ -263,12 +255,7 @@ public class RedisIndexedHttpSessionConfiguration extends SpringHttpSessionConfi if (StringUtils.hasText(redisNamespaceValue)) { this.redisNamespace = this.embeddedValueResolver.resolveStringValue(redisNamespaceValue); } - FlushMode flushMode = attributes.getEnum("flushMode"); - RedisFlushMode redisFlushMode = attributes.getEnum("redisFlushMode"); - if (flushMode == FlushMode.ON_SAVE && redisFlushMode != RedisFlushMode.ON_SAVE) { - flushMode = redisFlushMode.getFlushMode(); - } - this.flushMode = flushMode; + this.flushMode = attributes.getEnum("flushMode"); this.saveMode = attributes.getEnum("saveMode"); } diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/EnableRedisWebSession.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/EnableRedisWebSession.java index d5add08a..e1f6f963 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/EnableRedisWebSession.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/EnableRedisWebSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 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,12 +26,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory; import org.springframework.session.MapSession; -import org.springframework.session.ReactiveSessionRepository; import org.springframework.session.SaveMode; -import org.springframework.session.Session; import org.springframework.session.config.annotation.web.server.EnableSpringWebSession; import org.springframework.session.data.redis.ReactiveRedisSessionRepository; -import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.web.server.session.WebSessionManager; /** @@ -86,20 +83,6 @@ public @interface EnableRedisWebSession { */ String redisNamespace() default ReactiveRedisSessionRepository.DEFAULT_NAMESPACE; - /** - * Flush mode for the Redis sessions. The default is {@code ON_SAVE} which only - * updates the backing Redis when {@link ReactiveSessionRepository#save(Session)} is - * invoked. In a web environment this happens just before the HTTP response is - * committed. - *

- * Setting the value to {@code IMMEDIATE} will ensure that the any updates to the - * Session are immediately written to the Redis instance. - * @return the {@link RedisFlushMode} to use - * @deprecated since 2.2.0 as support {@code IMMEDIATE} is removed - */ - @Deprecated - RedisFlushMode redisFlushMode() default RedisFlushMode.ON_SAVE; - /** * Save mode for the session. The default is {@link SaveMode#ON_SET_ATTRIBUTE}, which * only saves changes made to session. diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/RedisWebSessionConfiguration.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/RedisWebSessionConfiguration.java index 77ec65c2..86f17e57 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/RedisWebSessionConfiguration.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/config/annotation/web/server/RedisWebSessionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 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. @@ -41,9 +41,7 @@ import org.springframework.session.SaveMode; import org.springframework.session.config.ReactiveSessionRepositoryCustomizer; import org.springframework.session.config.annotation.web.server.SpringWebSessionConfiguration; import org.springframework.session.data.redis.ReactiveRedisSessionRepository; -import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory; -import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.util.StringValueResolver; import org.springframework.web.server.session.WebSessionManager; @@ -99,11 +97,6 @@ public class RedisWebSessionConfiguration extends SpringWebSessionConfiguration this.redisNamespace = namespace; } - @Deprecated - public void setRedisFlushMode(RedisFlushMode redisFlushMode) { - Assert.notNull(redisFlushMode, "redisFlushMode cannot be null"); - } - public void setSaveMode(SaveMode saveMode) { this.saveMode = saveMode; } diff --git a/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/RedisSessionRepositoryTests.java b/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/RedisSessionRepositoryTests.java index d8a30fe1..3ea51709 100644 --- a/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/RedisSessionRepositoryTests.java +++ b/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/RedisSessionRepositoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2022 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. @@ -96,36 +96,18 @@ class RedisSessionRepositoryTests { .withMessage("defaultMaxInactiveInterval must not be null"); } - @Test - void setKeyNamespace_ValidNamespace_ShouldSetNamespace() { - this.sessionRepository.setKeyNamespace("test:"); - assertThat(ReflectionTestUtils.getField(this.sessionRepository, "keyNamespace")).isEqualTo("test:"); - } - @Test void setRedisKeyNamespace_ValidNamespace_ShouldSetNamespace() { this.sessionRepository.setRedisKeyNamespace("test"); assertThat(ReflectionTestUtils.getField(this.sessionRepository, "keyNamespace")).isEqualTo("test:"); } - @Test - void setKeyNamespace_NullNamespace_ShouldThrowException() { - assertThatIllegalArgumentException().isThrownBy(() -> this.sessionRepository.setKeyNamespace(null)) - .withMessage("keyNamespace must not be empty"); - } - @Test void setRedisKeyNamespace_NullNamespace_ShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> this.sessionRepository.setRedisKeyNamespace(null)) .withMessage("namespace must not be empty"); } - @Test - void setKeyNamespace_EmptyNamespace_ShouldThrowException() { - assertThatIllegalArgumentException().isThrownBy(() -> this.sessionRepository.setKeyNamespace(" ")) - .withMessage("keyNamespace must not be empty"); - } - @Test void setRedisKeyNamespace_EmptyNamespace_ShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> this.sessionRepository.setRedisKeyNamespace(" ")) diff --git a/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfigurationTests.java b/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfigurationTests.java index 1d0736b1..285e88e0 100644 --- a/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfigurationTests.java +++ b/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfigurationTests.java @@ -39,7 +39,6 @@ import org.springframework.mock.env.MockEnvironment; import org.springframework.session.FlushMode; import org.springframework.session.SaveMode; import org.springframework.session.config.SessionRepositoryCustomizer; -import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.session.data.redis.RedisSessionRepository; import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory; import org.springframework.test.util.ReflectionTestUtils; @@ -101,14 +100,6 @@ class RedisHttpSessionConfigurationTests { assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); } - @Test - void customFlushImmediatelyLegacy() { - registerAndRefresh(RedisConfig.class, CustomFlushImmediatelyLegacyConfiguration.class); - RedisSessionRepository sessionRepository = this.context.getBean(RedisSessionRepository.class); - assertThat(sessionRepository).isNotNull(); - assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); - } - @Test void setCustomFlushImmediately() { registerAndRefresh(RedisConfig.class, CustomFlushImmediatelySetConfiguration.class); @@ -117,14 +108,6 @@ class RedisHttpSessionConfigurationTests { assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); } - @Test - void setCustomFlushImmediatelyLegacy() { - registerAndRefresh(RedisConfig.class, CustomFlushImmediatelySetLegacyConfiguration.class); - RedisSessionRepository sessionRepository = this.context.getBean(RedisSessionRepository.class); - assertThat(sessionRepository).isNotNull(); - assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); - } - @Test void customSaveModeAnnotation() { registerAndRefresh(RedisConfig.class, CustomSaveModeExpressionAnnotationConfiguration.class); @@ -274,29 +257,12 @@ class RedisHttpSessionConfigurationTests { } - @Configuration - @SuppressWarnings("deprecation") - static class CustomFlushImmediatelySetLegacyConfiguration extends RedisHttpSessionConfiguration { - - CustomFlushImmediatelySetLegacyConfiguration() { - setRedisFlushMode(RedisFlushMode.IMMEDIATE); - } - - } - @Configuration @EnableRedisHttpSession(flushMode = FlushMode.IMMEDIATE) static class CustomFlushImmediatelyConfiguration { } - @Configuration - @EnableRedisHttpSession(redisFlushMode = RedisFlushMode.IMMEDIATE) - @SuppressWarnings("deprecation") - static class CustomFlushImmediatelyLegacyConfiguration { - - } - @EnableRedisHttpSession(saveMode = SaveMode.ALWAYS) static class CustomSaveModeExpressionAnnotationConfiguration { diff --git a/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfigurationTests.java b/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfigurationTests.java index 7e68d023..2292313e 100644 --- a/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfigurationTests.java +++ b/spring-session-data-redis/src/test/java/org/springframework/session/data/redis/config/annotation/web/http/RedisIndexedHttpSessionConfigurationTests.java @@ -42,7 +42,6 @@ import org.springframework.session.IndexResolver; import org.springframework.session.SaveMode; import org.springframework.session.Session; import org.springframework.session.config.SessionRepositoryCustomizer; -import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.session.data.redis.RedisIndexedSessionRepository; import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory; import org.springframework.test.util.ReflectionTestUtils; @@ -104,14 +103,6 @@ class RedisIndexedHttpSessionConfigurationTests { assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); } - @Test - void customFlushImmediatelyLegacy() { - registerAndRefresh(RedisConfig.class, CustomFlushImmediatelyLegacyConfiguration.class); - RedisIndexedSessionRepository sessionRepository = this.context.getBean(RedisIndexedSessionRepository.class); - assertThat(sessionRepository).isNotNull(); - assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); - } - @Test void setCustomFlushImmediately() { registerAndRefresh(RedisConfig.class, CustomFlushImmediatelySetConfiguration.class); @@ -120,14 +111,6 @@ class RedisIndexedHttpSessionConfigurationTests { assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); } - @Test - void setCustomFlushImmediatelyLegacy() { - registerAndRefresh(RedisConfig.class, CustomFlushImmediatelySetLegacyConfiguration.class); - RedisIndexedSessionRepository sessionRepository = this.context.getBean(RedisIndexedSessionRepository.class); - assertThat(sessionRepository).isNotNull(); - assertThat(ReflectionTestUtils.getField(sessionRepository, "flushMode")).isEqualTo(FlushMode.IMMEDIATE); - } - @Test void customCleanupCronSetter() { registerAndRefresh(RedisConfig.class, CustomCleanupCronExpressionSetterConfiguration.class); @@ -307,29 +290,12 @@ class RedisIndexedHttpSessionConfigurationTests { } - @Configuration - @SuppressWarnings("deprecation") - static class CustomFlushImmediatelySetLegacyConfiguration extends RedisIndexedHttpSessionConfiguration { - - CustomFlushImmediatelySetLegacyConfiguration() { - setRedisFlushMode(RedisFlushMode.IMMEDIATE); - } - - } - @Configuration @EnableRedisHttpSession(flushMode = FlushMode.IMMEDIATE, enableIndexingAndEvents = true) static class CustomFlushImmediatelyConfiguration { } - @Configuration - @EnableRedisHttpSession(redisFlushMode = RedisFlushMode.IMMEDIATE, enableIndexingAndEvents = true) - @SuppressWarnings("deprecation") - static class CustomFlushImmediatelyLegacyConfiguration { - - } - @Configuration static class CustomCleanupCronExpressionSetterConfiguration extends RedisIndexedHttpSessionConfiguration { diff --git a/spring-session-samples/spring-session-sample-boot-redis-simple/src/main/java/sample/config/SessionConfig.java b/spring-session-samples/spring-session-sample-boot-redis-simple/src/main/java/sample/config/SessionConfig.java index 27b13835..aa2eb6dc 100644 --- a/spring-session-samples/spring-session-sample-boot-redis-simple/src/main/java/sample/config/SessionConfig.java +++ b/spring-session-samples/spring-session-sample-boot-redis-simple/src/main/java/sample/config/SessionConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2022 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. @@ -65,7 +65,7 @@ public class SessionConfig { if (timeout != null) { sessionRepository.setDefaultMaxInactiveInterval(timeout); } - sessionRepository.setKeyNamespace(this.redisSessionProperties.getNamespace()); + sessionRepository.setRedisKeyNamespace(this.redisSessionProperties.getNamespace()); sessionRepository.setFlushMode(this.redisSessionProperties.getFlushMode()); sessionRepository.setSaveMode(this.redisSessionProperties.getSaveMode()); return sessionRepository;