Skip to content

Commit 3388422

Browse files
committed
Merge branch 'java-7' of github.com:jcoleman/tomcat-redis-session-manager into java-7
2 parents fdde911 + 08ec144 commit 3388422

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ public byte[] serializeFrom(HttpSession session) throws IOException {
1919

2020
RedisSession redisSession = (RedisSession) session;
2121
ByteArrayOutputStream bos = new ByteArrayOutputStream();
22-
ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(bos));
23-
oos.writeLong(redisSession.getCreationTime());
24-
redisSession.writeObjectData(oos);
25-
26-
oos.close();
22+
try (ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(bos))) {
23+
oos.writeLong(redisSession.getCreationTime());
24+
redisSession.writeObjectData(oos);
25+
}
2726

2827
return bos.toByteArray();
2928
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public HashMap<String, Object> getChangedAttributes() {
4242
}
4343

4444
public void resetDirtyTracking() {
45-
changedAttributes = new HashMap<String, Object>();
45+
changedAttributes = new HashMap<>();
4646
dirty = false;
4747
}
4848

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public class RedisSessionManager extends ManagerBase implements Lifecycle {
4141
protected JedisPool connectionPool;
4242

4343
protected RedisSessionHandlerValve handlerValve;
44-
protected ThreadLocal<RedisSession> currentSession = new ThreadLocal<RedisSession>();
45-
protected ThreadLocal<String> currentSessionId = new ThreadLocal<String>();
46-
protected ThreadLocal<Boolean> currentSessionIsPersisted = new ThreadLocal<Boolean>();
44+
protected ThreadLocal<RedisSession> currentSession = new ThreadLocal<>();
45+
protected ThreadLocal<String> currentSessionId = new ThreadLocal<>();
46+
protected ThreadLocal<Boolean> currentSessionIsPersisted = new ThreadLocal<>();
4747
protected Serializer serializer;
4848

4949
protected static String name = "RedisSessionManager";
@@ -197,13 +197,7 @@ protected synchronized void startInternal() throws LifecycleException {
197197

198198
try {
199199
initializeSerializer();
200-
} catch (ClassNotFoundException e) {
201-
log.fatal("Unable to load serializer", e);
202-
throw new LifecycleException(e);
203-
} catch (InstantiationException e) {
204-
log.fatal("Unable to load serializer", e);
205-
throw new LifecycleException(e);
206-
} catch (IllegalAccessException e) {
200+
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
207201
log.fatal("Unable to load serializer", e);
208202
throw new LifecycleException(e);
209203
}

0 commit comments

Comments
 (0)