408077 HashSessionManager leaves file handles open after being stopped
This commit is contained in:
parent
8a1ea2f69c
commit
51c1017b3d
|
@ -37,6 +37,7 @@ import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
|
import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
@ -520,8 +521,7 @@ public class HashSessionManager extends AbstractSessionManager
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (in != null)
|
if (in != null) IO.close(in);
|
||||||
try {in.close();} catch (Exception x) {__log.ignore(x);}
|
|
||||||
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
|
@ -568,30 +568,41 @@ public class HashSessionManager extends AbstractSessionManager
|
||||||
* defaultReadObject
|
* defaultReadObject
|
||||||
*/
|
*/
|
||||||
DataInputStream in = new DataInputStream(is);
|
DataInputStream in = new DataInputStream(is);
|
||||||
String clusterId = in.readUTF();
|
try
|
||||||
in.readUTF(); // nodeId
|
|
||||||
long created = in.readLong();
|
|
||||||
long accessed = in.readLong();
|
|
||||||
int requests = in.readInt();
|
|
||||||
|
|
||||||
if (session == null)
|
|
||||||
session = (HashedSession)newSession(created, accessed, clusterId);
|
|
||||||
session.setRequests(requests);
|
|
||||||
int size = in.readInt();
|
|
||||||
if (size>0)
|
|
||||||
{
|
{
|
||||||
ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(in);
|
String clusterId = in.readUTF();
|
||||||
for (int i=0; i<size;i++)
|
in.readUTF(); // nodeId
|
||||||
|
long created = in.readLong();
|
||||||
|
long accessed = in.readLong();
|
||||||
|
int requests = in.readInt();
|
||||||
|
|
||||||
|
if (session == null)
|
||||||
|
session = (HashedSession)newSession(created, accessed, clusterId);
|
||||||
|
session.setRequests(requests);
|
||||||
|
int size = in.readInt();
|
||||||
|
if (size>0)
|
||||||
{
|
{
|
||||||
String key = ois.readUTF();
|
ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(in);
|
||||||
Object value = ois.readObject();
|
try
|
||||||
session.setAttribute(key,value);
|
{
|
||||||
|
for (int i=0; i<size;i++)
|
||||||
|
{
|
||||||
|
String key = ois.readUTF();
|
||||||
|
Object value = ois.readObject();
|
||||||
|
session.setAttribute(key,value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IO.close(ois);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ois.close();
|
return session;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IO.close(in);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
in.close();
|
|
||||||
return session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ public class HashedSession extends AbstractSession
|
||||||
fos = new FileOutputStream(file);
|
fos = new FileOutputStream(file);
|
||||||
willPassivate();
|
willPassivate();
|
||||||
save(fos);
|
save(fos);
|
||||||
|
IO.close(fos);
|
||||||
if (reactivate)
|
if (reactivate)
|
||||||
didActivate();
|
didActivate();
|
||||||
else
|
else
|
||||||
|
@ -129,14 +130,9 @@ public class HashedSession extends AbstractSession
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
saveFailed(); // We won't try again for this session
|
saveFailed(); // We won't try again for this session
|
||||||
if (fos != null)
|
if (fos != null) IO.close(fos);
|
||||||
{
|
if (file != null) file.delete(); // No point keeping the file if we didn't save the whole session
|
||||||
// Must not leave the file open if the saving failed
|
throw e;
|
||||||
IO.close(fos);
|
|
||||||
// No point keeping the file if we didn't save the whole session
|
|
||||||
file.delete();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,9 +188,10 @@ public class HashedSession extends AbstractSession
|
||||||
fis = new FileInputStream(file);
|
fis = new FileInputStream(file);
|
||||||
_idled = false;
|
_idled = false;
|
||||||
_hashSessionManager.restoreSession(fis, this);
|
_hashSessionManager.restoreSession(fis, this);
|
||||||
|
IO.close(fis);
|
||||||
didActivate();
|
|
||||||
|
|
||||||
|
didActivate();
|
||||||
|
|
||||||
// If we are doing period saves, then there is no point deleting at this point
|
// If we are doing period saves, then there is no point deleting at this point
|
||||||
if (_hashSessionManager._savePeriodMs == 0)
|
if (_hashSessionManager._savePeriodMs == 0)
|
||||||
file.delete();
|
file.delete();
|
||||||
|
@ -202,7 +199,7 @@ public class HashedSession extends AbstractSession
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOG.warn("Problem de-idling session " + super.getId(), e);
|
LOG.warn("Problem de-idling session " + super.getId(), e);
|
||||||
IO.close(fis);
|
if (fis != null) IO.close(fis);//Must ensure closed before invalidate
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue