Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-02-19 03:59:31 +0000
committerJan Bartel2014-02-19 03:59:31 +0000
commitfc7e353394da47b58364afbcbd0bd50877d8b905 (patch)
tree77ec4881edbbe08dc7aa25d07eb1fb9adc04570c /jetty-nosql/src
parent8384b0febeb868aa6985f582a2233b6139927092 (diff)
downloadorg.eclipse.jetty.project-fc7e353394da47b58364afbcbd0bd50877d8b905.tar.gz
org.eclipse.jetty.project-fc7e353394da47b58364afbcbd0bd50877d8b905.tar.xz
org.eclipse.jetty.project-fc7e353394da47b58364afbcbd0bd50877d8b905.zip
373952 Ensure MongoSessionManager un/binds session attributes on refresh only if necessary
Diffstat (limited to 'jetty-nosql/src')
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
index 867233add2..d8556da87a 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
@@ -365,13 +365,16 @@ public class MongoSessionManager extends NoSqlSessionManager
// followed by bindings and then activation.
session.willPassivate();
try
- {
- session.clearAttributes();
-
- DBObject attrs = (DBObject)getNestedValue(o,getContextKey());
-
- if (attrs != null)
+ {
+ DBObject attrs = (DBObject)getNestedValue(o,getContextKey());
+ //if disk version now has no attributes, get rid of them
+ if (attrs == null || attrs.keySet().size() == 0)
+ {
+ session.clearAttributes();
+ }
+ else
{
+ //iterate over the names of the attributes on the disk version, updating the value
for (String name : attrs.keySet())
{
//skip special metadata field which is not one of the session attributes
@@ -381,23 +384,25 @@ public class MongoSessionManager extends NoSqlSessionManager
String attr = decodeName(name);
Object value = decodeValue(attrs.get(name));
- if (attrs.keySet().contains(name))
- {
+ //session does not already contain this attribute, so bind it
+ if (session.getAttribute(attr) == null)
+ {
session.doPutOrRemove(attr,value);
session.bindValue(attr,value);
}
- else
+ else //session already contains this attribute, update its value
{
session.doPutOrRemove(attr,value);
}
+
}
// cleanup, remove values from session, that don't exist in data anymore:
- for (String name : session.getNames())
+ for (String str : session.getNames())
{
- if (!attrs.keySet().contains(name))
+ if (!attrs.keySet().contains(str))
{
- session.doPutOrRemove(name,null);
- session.unbindValue(name,session.getAttribute(name));
+ session.doPutOrRemove(str,null);
+ session.unbindValue(str,session.getAttribute(str));
}
}
}

Back to the top