Skip to content

Commit 456db4b

Browse files
committed
Move RedisSession serialization details to RedisSession.
Note: order of serialized attributes has changed. This change will mean that all currently serialized sessions will be invalid.
1 parent 1fcbb19 commit 456db4b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/com/orangefunction/tomcat/redissessions/JavaSerializer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public byte[] serializeFrom(HttpSession session) throws IOException {
2020
RedisSession redisSession = (RedisSession) session;
2121
ByteArrayOutputStream bos = new ByteArrayOutputStream();
2222
try (ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(bos))) {
23-
oos.writeLong(redisSession.getCreationTime());
2423
redisSession.writeObjectData(oos);
2524
}
2625

@@ -35,7 +34,6 @@ public HttpSession deserializeInto(byte[] data, HttpSession session) throws IOEx
3534
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(data));
3635
ObjectInputStream ois = new CustomObjectInputStream(bis, loader);
3736
) {
38-
redisSession.setCreationTime(ois.readLong());
3937
redisSession.readObjectData(ois);
4038
return session;
4139
}

src/main/java/com/orangefunction/tomcat/redissessions/RedisSession.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,16 @@ public void setPrincipal(Principal principal) {
105105
super.setPrincipal(principal);
106106
}
107107

108+
@Override
109+
public void writeObjectData(java.io.ObjectOutputStream out) throws IOException {
110+
super.writeObjectData(out);
111+
out.writeLong(this.getCreationTime());
112+
}
113+
114+
@Override
115+
public void readObjectData(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
116+
super.readObjectData(in);
117+
this.setCreationTime(in.readLong());
118+
}
119+
108120
}

0 commit comments

Comments
 (0)