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
I'm not sure about the name just yet, but we should have a
SessionRepositoryimplementation 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):Relates to #280