JETTY-1484 Add option for HashSessionManager to delete session files if it can't restore them
This commit is contained in:
parent
5f0fdb7d32
commit
b949fb7622
|
@ -60,6 +60,10 @@ public class HashSessionManager extends AbstractSessionManager
|
||||||
File _storeDir;
|
File _storeDir;
|
||||||
private boolean _lazyLoad=false;
|
private boolean _lazyLoad=false;
|
||||||
private volatile boolean _sessionsLoaded=false;
|
private volatile boolean _sessionsLoaded=false;
|
||||||
|
private boolean _deleteUnrestorableSessions=false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public HashSessionManager()
|
public HashSessionManager()
|
||||||
|
@ -434,6 +438,18 @@ public class HashSessionManager extends AbstractSessionManager
|
||||||
return _lazyLoad;
|
return _lazyLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
public boolean isDeleteUnrestorableSessions()
|
||||||
|
{
|
||||||
|
return _deleteUnrestorableSessions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
public void setDeleteUnrestorableSessions(boolean deleteUnrestorableSessions)
|
||||||
|
{
|
||||||
|
_deleteUnrestorableSessions = deleteUnrestorableSessions;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public void restoreSessions () throws Exception
|
public void restoreSessions () throws Exception
|
||||||
{
|
{
|
||||||
|
@ -460,9 +476,9 @@ public class HashSessionManager extends AbstractSessionManager
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
protected synchronized HashedSession restoreSession(String idInCuster)
|
protected synchronized HashedSession restoreSession(String idInCuster)
|
||||||
{
|
{
|
||||||
|
File file = new File(_storeDir,idInCuster);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File file = new File(_storeDir,idInCuster);
|
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
{
|
{
|
||||||
FileInputStream in = new FileInputStream(file);
|
FileInputStream in = new FileInputStream(file);
|
||||||
|
@ -476,7 +492,18 @@ public class HashSessionManager extends AbstractSessionManager
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (isDeleteUnrestorableSessions())
|
||||||
|
{
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
file.delete();
|
||||||
|
__log.warn("Deleting file for unrestorable session "+idInCuster, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
__log.warn("Problem restoring session "+idInCuster, e);
|
__log.warn("Problem restoring session "+idInCuster, e);
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue