I implemented my own Store which uses Redis to persist sessions (I'm using
Jedis as the interface library). I copied most of the load()/save() code
from FileStore. When my Store loads the session from Redis I consistently
get java.io.StreamCorruptedException: Inconsistent vector internals. Any
ideas on why this might be happening?

Here's the relevant code:
public Session load(String sessionId) throws ClassNotFoundException,
IOException {
System.out.println("JEDIS load " + sessionId);
String key = getKey(sessionId);
byte[] bytes = jedis.get(key.getBytes(UTF8));
System.out.println("JEDIS loaded " + bytes.length + " bytes");

ClassLoader oldThreadContextCL =
manager.getContext().bind(Globals.IS_SECURITY_ENABLED, null);
try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bis)) {
StandardSession session = (StandardSession) manager.createEmptySession();

return session;
} catch (Exception e) {
return null;
} finally {

public void save(Session session) throws IOException {
System.out.println("JEDIS save " + session.getId());
String key = getKey(session.getId());
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos)) {
jedis.set(key.getBytes(UTF8), bos.toByteArray());

Reply via email to