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: @Override 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(); session.readObjectData(ois); session.setManager(manager); return session; } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); return null; } finally { manager.getContext().unbind(Globals.IS_SECURITY_ENABLED, oldThreadContextCL); } } @Override 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)) { ((StandardSession)session).writeObjectData(oos); jedis.set(key.getBytes(UTF8), bos.toByteArray()); } }