Session.delete -> deleteById

Fixes gh-809
This commit is contained in:
Rob Winch
2017-06-22 21:24:20 -05:00
parent 0127ef9f9b
commit c6c6beb40c
14 changed files with 25 additions and 25 deletions

View File

@@ -60,7 +60,7 @@ public class IndexController {
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
principal.getName()).keySet();
if (usersSessionIds.contains(sessionIdToDelete)) {
this.sessions.delete(sessionIdToDelete);
this.sessions.deleteById(sessionIdToDelete);
}
return "redirect:/";

View File

@@ -87,13 +87,13 @@ public class MapSessionRepository implements SessionRepository<Session> {
return null;
}
if (saved.isExpired()) {
delete(saved.getId());
deleteById(saved.getId());
return null;
}
return new MapSession(saved);
}
public void delete(String id) {
public void deleteById(String id) {
this.sessions.remove(id);
}

View File

@@ -69,5 +69,5 @@ public interface SessionRepository<S extends Session> {
* if the {@link Session} is not found.
* @param id the {@link org.springframework.session.Session#getId()} to delete
*/
void delete(String id);
void deleteById(String id);
}

View File

@@ -284,7 +284,7 @@ public class SessionRepositoryFilter<S extends Session>
attrs.put(attrName, value);
}
SessionRepositoryFilter.this.sessionRepository.delete(session.getId());
SessionRepositoryFilter.this.sessionRepository.deleteById(session.getId());
HttpSessionWrapper original = getCurrentSession();
setCurrentSession(null);
@@ -413,7 +413,7 @@ public class SessionRepositoryFilter<S extends Session>
super.invalidate();
SessionRepositoryRequestWrapper.this.requestedSessionInvalidated = true;
setCurrentSession(null);
SessionRepositoryFilter.this.sessionRepository.delete(getId());
SessionRepositoryFilter.this.sessionRepository.deleteById(getId());
}
}
}

View File

@@ -92,7 +92,7 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
this.registry.clear();
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
assertThat(this.repository.findById(toSave.getId())).isNull();
assertThat(this.registry.<SessionDestroyedEvent>getEvent(toSave.getId()))
@@ -123,7 +123,7 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
assertThat(session.<String>getAttribute("a")).isEqualTo(Optional.of("b"));
assertThat(session.<String>getAttribute("1")).isEqualTo(Optional.of("2"));
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
}
@Test
@@ -140,7 +140,7 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
assertThat(findByPrincipalName).hasSize(1);
assertThat(findByPrincipalName.keySet()).containsOnly(toSave.getId());
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
assertThat(this.registry.receivedEvent(toSave.getId())).isTrue();
findByPrincipalName = this.repository.findByIndexNameAndIndexValue(INDEX_NAME,
@@ -310,7 +310,7 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
assertThat(findByPrincipalName).hasSize(1);
assertThat(findByPrincipalName.keySet()).containsOnly(toSave.getId());
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
assertThat(this.registry.receivedEvent(toSave.getId())).isTrue();
findByPrincipalName = this.repository.findByIndexNameAndIndexValue(INDEX_NAME,

View File

@@ -466,7 +466,7 @@ public class RedisOperationsSessionRepository implements
return loaded;
}
public void delete(String sessionId) {
public void deleteById(String sessionId) {
RedisSession session = getSession(sessionId, true);
if (session == null) {
return;

View File

@@ -344,7 +344,7 @@ public class RedisOperationsSessionRepositoryTests {
.willReturn(this.boundSetOperations);
String id = expected.getId();
this.redisRepository.delete(id);
this.redisRepository.deleteById(id);
assertThat(getDelta().get(RedisOperationsSessionRepository.MAX_INACTIVE_ATTR))
.isEqualTo(0);
@@ -358,7 +358,7 @@ public class RedisOperationsSessionRepositoryTests {
.willReturn(this.boundHashOperations);
String id = "abc";
this.redisRepository.delete(id);
this.redisRepository.deleteById(id);
verify(this.redisOperations, times(0)).delete(anyString());
verify(this.redisOperations, times(0)).delete(anyString());
}

View File

@@ -55,7 +55,7 @@ public abstract class AbstractHazelcastRepositoryITests {
assertThat(hazelcastMap.size()).isEqualTo(1);
assertThat(hazelcastMap.get(sessionId)).isEqualTo(sessionToSave);
this.repository.delete(sessionId);
this.repository.deleteById(sessionId);
assertThat(hazelcastMap.size()).isEqualTo(0);
}

View File

@@ -135,7 +135,7 @@ public class EnableHazelcastHttpSessionEventsTests<S extends Session> {
.isInstanceOf(SessionCreatedEvent.class);
this.registry.clear();
this.repository.delete(sessionToSave.getId());
this.repository.deleteById(sessionToSave.getId());
assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
assertThat(this.registry.<SessionDeletedEvent>getEvent(sessionToSave.getId()))

View File

@@ -217,13 +217,13 @@ public class HazelcastSessionRepository implements
return null;
}
if (saved.isExpired()) {
delete(saved.getId());
deleteById(saved.getId());
return null;
}
return new HazelcastSession(saved);
}
public void delete(String id) {
public void deleteById(String id) {
this.sessions.remove(id);
}

View File

@@ -280,7 +280,7 @@ public class HazelcastSessionRepositoryTests {
public void delete() {
String sessionId = "testSessionId";
this.repository.delete(sessionId);
this.repository.deleteById(sessionId);
verify(this.sessions, times(1)).remove(eq(sessionId));
}

View File

@@ -109,7 +109,7 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
assertThat(session.<String>getAttribute(expectedAttributeName))
.isEqualTo(toSave.getAttribute(expectedAttributeName));
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
assertThat(this.repository.findById(toSave.getId())).isNull();
}
@@ -142,7 +142,7 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
assertThat(session.<String>getAttribute("a")).isEqualTo(Optional.of("b"));
assertThat(session.<String>getAttribute("1")).isEqualTo(Optional.of("2"));
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
}
@Test
@@ -180,7 +180,7 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
assertThat(findByPrincipalName).hasSize(1);
assertThat(findByPrincipalName.keySet()).containsOnly(toSave.getId());
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
findByPrincipalName = this.repository.findByIndexNameAndIndexValue(INDEX_NAME,
principalName);
@@ -354,7 +354,7 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
assertThat(findByPrincipalName).hasSize(1);
assertThat(findByPrincipalName.keySet()).containsOnly(toSave.getId());
this.repository.delete(toSave.getId());
this.repository.deleteById(toSave.getId());
findByPrincipalName = this.repository.findByIndexNameAndIndexValue(INDEX_NAME,
getSecurityName());

View File

@@ -476,7 +476,7 @@ public class JdbcOperationsSessionRepository implements
if (session != null) {
if (session.isExpired()) {
delete(id);
deleteById(id);
}
else {
return new JdbcSession(session);
@@ -485,7 +485,7 @@ public class JdbcOperationsSessionRepository implements
return null;
}
public void delete(final String id) {
public void deleteById(final String id) {
this.transactionOperations.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {

View File

@@ -455,7 +455,7 @@ public class JdbcOperationsSessionRepositoryTests {
public void delete() {
String sessionId = "testSessionId";
this.repository.delete(sessionId);
this.repository.deleteById(sessionId);
assertPropagationRequiresNew();
verify(this.jdbcOperations, times(1)).update(startsWith("DELETE"), eq(sessionId));