From fff825a9979b7d1c6127a0fe274536a269c42c7b Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 5 Nov 2012 16:26:20 +1100 Subject: [PATCH] 393494 HashSessionManager can't delete unrestorable sessions on Windows --- .../server/session/HashSessionManager.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java index 7f888a99d72..0f789328fd5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java @@ -482,32 +482,40 @@ public class HashSessionManager extends AbstractSessionManager protected synchronized HashedSession restoreSession(String idInCuster) { File file = new File(_storeDir,idInCuster); + FileInputStream in = null; + Exception error = null; try { if (file.exists()) { - FileInputStream in = new FileInputStream(file); + in = new FileInputStream(file); HashedSession session = restoreSession(in, null); - in.close(); addSession(session, false); session.didActivate(); - file.delete(); return session; } } catch (Exception e) { - - if (isDeleteUnrestorableSessions()) + error = e; + } + finally + { + if (in != null) + try {in.close();} catch (Exception x) {__log.ignore(x);} + + if (error != null) { - if (file.exists()) + if (isDeleteUnrestorableSessions() && file.exists()) { file.delete(); - __log.warn("Deleting file for unrestorable session "+idInCuster, e); + __log.warn("Deleting file for unrestorable session "+idInCuster, error); } + else + __log.warn("Problem restoring session "+idInCuster, error); } else - __log.warn("Problem restoring session "+idInCuster, e); + file.delete(); //delete successfully restored file } return null;