Remove unnecessary Redis commands in RedisIndexedSessionRepository#save
See: #1331
This commit is contained in:
committed by
Eleftheria Stein-Kousathana
parent
090a10fb10
commit
301e65c2b9
@@ -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 @@ package org.springframework.session.data.redis;
|
||||
|
||||
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 @@ class RedisIndexedSessionRepositoryITests extends AbstractRedisITests {
|
||||
.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<Map.Entry<Object, Object>> entries = this.redis.boundHashOps(key).entries().entrySet();
|
||||
assertThat(entries).extracting(Map.Entry::getKey).doesNotContain("sessionAttr:a");
|
||||
}
|
||||
|
||||
@Test
|
||||
void putAllOnSingleAttrDoesNotRemoveOld() {
|
||||
RedisSession toSave = this.repository.createSession();
|
||||
|
||||
@@ -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 @@ public class RedisIndexedSessionRepository
|
||||
return;
|
||||
}
|
||||
String sessionId = getId();
|
||||
BoundHashOperations<Object, Object, Object> 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 @@ public class RedisIndexedSessionRepository
|
||||
.add(sessionId);
|
||||
}
|
||||
}
|
||||
for (final Map.Entry<String, Object> attribute : this.delta.entrySet()) {
|
||||
if (attribute.getValue() == null) {
|
||||
boundHashOperations.delete(attribute.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
this.delta = new HashMap<>(this.delta.size());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user