From 3d6711b4ab6a43ba76a0c92da3a7a25a05094ef9 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 20 Aug 2013 13:01:52 -0500 Subject: [PATCH] [Bug 413484] setAttribute in nosql session management better handles _dirty status --- .../org/eclipse/jetty/nosql/NoSqlSession.java | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSession.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSession.java index c0784d91dc4..58861e021ea 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSession.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSession.java @@ -63,16 +63,57 @@ public class NoSqlSession extends AbstractSession { synchronized (this) { - if (_dirty==null) - _dirty=new HashSet(); - _dirty.add(name); Object old = super.doPutOrRemove(name,value); + if (_manager.getSavePeriod()==-2) + { save(true); + } return old; } } + + + @Override + public void setAttribute(String name, Object value) + { + if ( updateAttribute(name,value) ) + { + if (_dirty==null) + { + _dirty=new HashSet(); + } + + _dirty.add(name); + } + } + + /* + * a boolean version of the setAttribute method that lets us manage the _dirty set + */ + protected boolean updateAttribute (String name, Object value) + { + Object old=null; + synchronized (this) + { + checkValid(); + old=doPutOrRemove(name,value); + } + + if (value==null || !value.equals(old)) + { + if (old!=null) + unbindValue(name,old); + if (value!=null) + bindValue(name,value); + + _manager.doSessionAttributeListeners(this,name,old,value); + return true; + } + return false; + } + /* ------------------------------------------------------------ */ @Override protected void checkValid() throws IllegalStateException