455476 MongoSessionManager sessions always expire at create + maxIdle

This commit is contained in:
Jan Bartel 2014-12-17 17:08:13 +01:00
parent 89a9aa2472
commit 5e8e0b11f5
2 changed files with 16 additions and 7 deletions

View File

@ -259,6 +259,7 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
*/
protected void purge()
{
__log.debug("PURGING");
BasicDBObject invalidQuery = new BasicDBObject();
invalidQuery.put(MongoSessionManager.__ACCESSED, new BasicDBObject("$lt",System.currentTimeMillis() - _purgeInvalidAge));
@ -432,6 +433,8 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
_scavengerTask = _scheduler.schedule(new Scavenger(), _scavengePeriod, TimeUnit.MILLISECONDS);
}
else if (__log.isDebugEnabled())
__log.debug("Scavenger disabled");
//if purging is enabled, setup the purge thread
@ -444,6 +447,8 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
}
_purgerTask = _scheduler.schedule(new Purger(), _purgeDelay, TimeUnit.MILLISECONDS);
}
else if (__log.isDebugEnabled())
__log.debug("Purger disabled");
}
}

View File

@ -42,6 +42,8 @@ import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.MongoException;
import com.mongodb.WriteConcern;
import com.mongodb.WriteResult;
/**
@ -268,7 +270,7 @@ public class MongoSessionManager extends NoSqlSessionManager
Long currentExpiry = (Long)o.get(__EXPIRY);
if (currentMaxIdle != null && getMaxInactiveInterval() > 0 && getMaxInactiveInterval() < currentMaxIdle)
sets.put(__MAX_IDLE, getMaxInactiveInterval());
if (currentExpiry != null && expiry > 0 && expiry < currentExpiry)
if (currentExpiry != null && expiry > 0 && expiry != currentExpiry)
sets.put(__EXPIRY, currentExpiry);
}
}
@ -302,8 +304,10 @@ public class MongoSessionManager extends NoSqlSessionManager
if (!unsets.isEmpty())
update.put("$unset",unsets);
_dbSessions.update(key,update,upsert,false);
__log.debug("MongoSessionManager:save:db.sessions.update( {}, {}, true) ", key, update);
_dbSessions.update(key,update,upsert,false,WriteConcern.SAFE);
if (__log.isDebugEnabled())
__log.debug("MongoSessionManager:save:db.sessions.update( {}, {} )", key, update);
if (activateAfterSave)
session.didActivate();
@ -421,7 +425,7 @@ public class MongoSessionManager extends NoSqlSessionManager
update.put("$set",sets);
}
_dbSessions.update(key,update,false,false);
_dbSessions.update(key,update,false,false,WriteConcern.SAFE);
session.didActivate();
@ -520,7 +524,7 @@ public class MongoSessionManager extends NoSqlSessionManager
BasicDBObject unsets = new BasicDBObject();
unsets.put(getContextKey(),1);
remove.put("$unset",unsets);
_dbSessions.update(key,remove);
_dbSessions.update(key,remove,false,false,WriteConcern.SAFE);
return true;
}
@ -556,7 +560,7 @@ public class MongoSessionManager extends NoSqlSessionManager
update.put("$set",sets);
BasicDBObject key = new BasicDBObject(__ID,idInCluster);
_dbSessions.update(key,update);
_dbSessions.update(key,update,false,false,WriteConcern.SAFE);
}
}
@ -573,7 +577,7 @@ public class MongoSessionManager extends NoSqlSessionManager
BasicDBObject sets = new BasicDBObject();
BasicDBObject update = new BasicDBObject(__ID, newClusterId);
sets.put("$set", update);
_dbSessions.update(key, sets, false, false);
_dbSessions.update(key, sets, false, false,WriteConcern.SAFE);
}
/*------------------------------------------------------------ */