Add ExpiringSession setLastAccessedTime

Previously SessionRepository had to update the lastAccessTime when it was
loaded. This prevented inspecting the last access time. For example,
listing all the sessions for a specific user. Furthermore, it is
unintuitive that a read operation would update attributes on the domain
model.

This change introduces ExpiringSession setLastAccessedTime to allow setting
the expiration on the interface. This means that the SessionRepositoryFilter
can update the last accessed time.

Fixes gh-272
This commit is contained in:
Rob Winch
2015-11-17 10:47:42 -06:00
parent 8bd29c1ab2
commit ee09a9e863
8 changed files with 25 additions and 15 deletions

View File

@@ -94,6 +94,10 @@ public class MapSessionTests {
return "id";
}
public void setLastAccessedTime(long lastAccessedTime) {
throw new UnsupportedOperationException();
}
public long getLastAccessedTime() {
return 0;
}

View File

@@ -319,7 +319,7 @@ public class RedisOperationsSessionRepositoryTests {
assertThat(session.getAttribute(attrName)).isEqualTo(expected.getAttribute(attrName));
assertThat(session.getCreationTime()).isEqualTo(expected.getCreationTime());
assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(expected.getMaxInactiveIntervalInSeconds());
assertThat(session.getLastAccessedTime()).isGreaterThanOrEqualTo(now);
assertThat(session.getLastAccessedTime()).isEqualTo(expected.getLastAccessedTime());
}

View File

@@ -126,7 +126,7 @@ public class SessionRepositoryFilterTests {
}
});
Thread.sleep(10L);
Thread.sleep(1L);
nextRequest();
doFilter(new DoInFilter() {