diff --git a/spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/RedisIndexedSessionRepositoryITests.java b/spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/RedisIndexedSessionRepositoryITests.java index 4fcf13d90..3b62f128d 100644 --- a/spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/RedisIndexedSessionRepositoryITests.java +++ b/spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/RedisIndexedSessionRepositoryITests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -18,7 +18,6 @@ import java.nio.charset.StandardCharsets; import java.util.Map; -import java.util.Set; import java.util.UUID; import org.junit.jupiter.api.BeforeEach; @@ -135,22 +134,6 @@ void saves() throws InterruptedException { .isEqualTo(expectedAttributeValue); } - @Test - void removeAttributeRemovedAttributeKey() { - RedisSession toSave = this.repository.createSession(); - toSave.setAttribute("a", "b"); - this.repository.save(toSave); - - toSave.removeAttribute("a"); - this.repository.save(toSave); - - String id = toSave.getId(); - String key = "RedisIndexedSessionRepositoryITests:sessions:" + id; - - Set> entries = this.redis.boundHashOps(key).entries().entrySet(); - assertThat(entries).extracting(Map.Entry::getKey).doesNotContain("sessionAttr:a"); - } - @Test void putAllOnSingleAttrDoesNotRemoveOld() { RedisSession toSave = this.repository.createSession(); diff --git a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java index c30790e3b..b2ac59c52 100644 --- a/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java +++ b/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -792,8 +792,7 @@ private void saveDelta() { return; } String sessionId = getId(); - BoundHashOperations boundHashOperations = getSessionBoundHashOperations(sessionId); - boundHashOperations.putAll(this.delta); + getSessionBoundHashOperations(sessionId).putAll(this.delta); String principalSessionKey = getSessionAttrNameKey( FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME); String securityPrincipalSessionKey = getSessionAttrNameKey(SPRING_SECURITY_CONTEXT); @@ -812,11 +811,6 @@ private void saveDelta() { .add(sessionId); } } - for (final Map.Entry attribute : this.delta.entrySet()) { - if (attribute.getValue() == null) { - boundHashOperations.delete(attribute.getKey()); - } - } this.delta = new HashMap<>(this.delta.size());