Skip to content

Commit 344aa5a

Browse files
committed
Merge pull request #44 from farvilain/master
Using try-with-resources for never closed stream
2 parents e16d3cf + 810b48d commit 344aa5a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/com/radiadesign/catalina/session/JavaSerializer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public byte[] serializeFrom(HttpSession session) throws IOException {
3131
public HttpSession deserializeInto(byte[] data, HttpSession session) throws IOException, ClassNotFoundException {
3232

3333
RedisSession redisSession = (RedisSession) session;
34-
35-
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(data));
36-
37-
ObjectInputStream ois = new CustomObjectInputStream(bis, loader);
38-
redisSession.setCreationTime(ois.readLong());
39-
redisSession.readObjectData(ois);
40-
41-
return session;
34+
try(
35+
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(data));
36+
ObjectInputStream ois = new CustomObjectInputStream(bis, loader);
37+
) {
38+
redisSession.setCreationTime(ois.readLong());
39+
redisSession.readObjectData(ois);
40+
return session;
41+
}
4242
}
4343
}

0 commit comments

Comments
 (0)