You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2002/03/28 04:15:18 UTC
cvs commit: xml-axis/java/test/session TestSimpleSession.java
gdaniels 02/03/27 19:15:18
Modified: java/src/org/apache/axis/handlers SimpleSessionHandler.java
java/test/session TestSimpleSession.java
Log:
Fix serious bug in session timeouts.
Reported by kweiner@interactivebusiness.com (Ken Weiner) - thanks!
Revision Changes Path
1.16 +12 -8 xml-axis/java/src/org/apache/axis/handlers/SimpleSessionHandler.java
Index: SimpleSessionHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleSessionHandler.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SimpleSessionHandler.java 26 Mar 2002 16:40:35 -0000 1.15
+++ SimpleSessionHandler.java 28 Mar 2002 03:15:18 -0000 1.16
@@ -126,11 +126,11 @@
private long curSessionID = 0;
// Reap timed-out sessions on the first request after this many
- // milliseconds.
- private long reapPeriodicity = 30000;
+ // seconds.
+ private long reapPeriodicity = 30;
private long lastReapTime = 0;
- // By default, sessions time out after 1 minute of inactivity
+ // By default, sessions time out after 1 minute of inactivity (60 sec)
private int defaultSessionTimeout = 60;
/**
@@ -144,7 +144,7 @@
// Minimize synchronicity, just check in here, do reap later.
synchronized (this) {
- if (curTime > lastReapTime + reapPeriodicity) {
+ if (curTime > lastReapTime + (reapPeriodicity * 1000)) {
reap = true;
lastReapTime = curTime;
}
@@ -158,8 +158,8 @@
for (i = keys.iterator(); i.hasNext();) {
key = i.next();
SimpleSession session = (SimpleSession)activeSessions.get(key);
- if ((session.getTimeout() * 1000) >
- (curTime - session.getLastAccessTime())) {
+ if ((curTime - session.getLastAccessTime()) >
+ (session.getTimeout() * 1000)) {
log.debug(JavaUtils.getMessage("timeout00",
key.toString()));
@@ -300,7 +300,9 @@
}
/**
- * Set the reaper periodicity - convenience method for testing.
+ * Set the reaper periodicity in SECONDS
+ *
+ * Convenience method for testing.
*
* !!! TODO: Should be able to set this via options on the Handler
* or perhaps the engine.
@@ -311,7 +313,9 @@
}
/**
- * Set the default session timeout - again, for testing.
+ * Set the default session timeout in SECONDS
+ *
+ * Again, for testing.
*/
public void setDefaultSessionTimeout(int defaultSessionTimeout) {
this.defaultSessionTimeout = defaultSessionTimeout;
1.15 +3 -3 xml-axis/java/test/session/TestSimpleSession.java
Index: TestSimpleSession.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/session/TestSimpleSession.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TestSimpleSession.java 20 Feb 2002 18:59:22 -0000 1.14
+++ TestSimpleSession.java 28 Mar 2002 03:15:18 -0000 1.15
@@ -82,8 +82,8 @@
// Set up the server side
SimpleSessionHandler sessionHandler = new SimpleSessionHandler();
// Set a 3-second reap period, and a 3-second timeout
- sessionHandler.setReapPeriodicity(3000);
- sessionHandler.setDefaultSessionTimeout(3000);
+ sessionHandler.setReapPeriodicity(3);
+ sessionHandler.setDefaultSessionTimeout(3);
SOAPService service = new SOAPService(sessionHandler,
new RPCProvider(),
@@ -130,7 +130,7 @@
count.intValue());
// Wait around a few seconds to let the first session time out
- Thread.sleep(3000);
+ Thread.sleep(4000);
// And now we should get a new session, therefore going back to 1
count = (Integer)call.invoke("sessionTest", "counter", null);