spring-projects / spring-projects/spring-session
Add a SafeDeserializingSessionRepository
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 55
Description
I'm not sure about the name just yet, but we should have a SessionRepository implementation that can ignore specific set of exceptions to allow ignoring of deserialization exceptions (i.e. when a serialization UID changes). The implementation would look something like this, but would either allow for customizing the exceptions that are ignored or we would require updates to the existing implementations to ensure that they threw a consistent exception if deserialization failed (perfered):
public class SafeDeserializingSessionRepository<S extends ExpiringSession> implements SessionRepository<S> {
private final SessionRepository<S> repository;
public SafeDeserializingSessionRepository(SessionRepository<S> repository) {
this.repository = repository;
}
public S getSession(String id) {
try {
return repository.getSession(id);
} catch(SerializationException e) {
delete(id);
return null;
}
}
public S createSession() {
return repository.createSession();
}
public void save(S session) {
repository.save(session);
}
public void delete(String id) {
repository.delete(id);
}
}
Relates to #280
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SessionRepository interface and its existing implementations to understand how deserialization failures are surfaced. Review related issue #280 and determine whether the intended design is configurable ignored exceptions or a consistent deserialization exception. Done means the chosen design is implemented and covered by tests for failed deserialization and normal session operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100