429357 JDBCSessionManager.Session.removeAttribute don't set dirty flag if attribute already removed
This commit is contained in:
parent
4de73d508b
commit
b405ad8c4f
|
@ -77,7 +77,11 @@ public class NoSqlSession extends AbstractSession
|
|||
@Override
|
||||
public void setAttribute(String name, Object value)
|
||||
{
|
||||
if ( updateAttribute(name,value) )
|
||||
Object old = changeAttribute(name,value);
|
||||
if (value == null && old == null)
|
||||
return; //not dirty, no change
|
||||
|
||||
if (value==null || !value.equals(old))
|
||||
{
|
||||
if (_dirty==null)
|
||||
{
|
||||
|
@ -96,30 +100,7 @@ public class NoSqlSession extends AbstractSession
|
|||
super.timeout();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
|
|
@ -443,7 +443,7 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI
|
|||
@Override
|
||||
public void putValue(java.lang.String name, java.lang.Object value) throws IllegalStateException
|
||||
{
|
||||
setAttribute(name,value);
|
||||
changeAttribute(name,value);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -481,10 +481,16 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI
|
|||
@Override
|
||||
public void setAttribute(String name, Object value)
|
||||
{
|
||||
updateAttribute(name,value);
|
||||
changeAttribute(name,value);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param name
|
||||
* @param value
|
||||
* @deprecated use changeAttribute(String,Object) instead
|
||||
* @return
|
||||
*/
|
||||
protected boolean updateAttribute (String name, Object value)
|
||||
{
|
||||
Object old=null;
|
||||
|
@ -506,6 +512,53 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Either set (perhaps replace) or remove the value of the attribute
|
||||
* in the session. The appropriate session attribute listeners are
|
||||
* also called.
|
||||
*
|
||||
* @param name
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
protected Object changeAttribute (String name, Object value)
|
||||
{
|
||||
Object old=null;
|
||||
synchronized (this)
|
||||
{
|
||||
checkValid();
|
||||
old=doPutOrRemove(name,value);
|
||||
}
|
||||
|
||||
callSessionAttributeListeners(name, value, old);
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Call binding and attribute listeners based on the new and old
|
||||
* values of the attribute.
|
||||
*
|
||||
* @param name name of the attribute
|
||||
* @param newValue new value of the attribute
|
||||
* @param oldValue previous value of the attribute
|
||||
*/
|
||||
protected void callSessionAttributeListeners (String name, Object newValue, Object oldValue)
|
||||
{
|
||||
if (newValue==null || !newValue.equals(oldValue))
|
||||
{
|
||||
if (oldValue!=null)
|
||||
unbindValue(name,oldValue);
|
||||
if (newValue!=null)
|
||||
bindValue(name,newValue);
|
||||
|
||||
_manager.doSessionAttributeListeners(this,name,oldValue,newValue);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void addAttributes(Map<String,Object> map)
|
||||
|
|
|
@ -246,15 +246,19 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
@Override
|
||||
public void setAttribute (String name, Object value)
|
||||
{
|
||||
updateAttribute(name, value);
|
||||
Object old = changeAttribute(name, value);
|
||||
if (value == null && old == null)
|
||||
return; //if same as remove attribute but attribute was already removed, no change
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute (String name)
|
||||
{
|
||||
super.removeAttribute(name);
|
||||
_dirty=true;
|
||||
Object old = changeAttribute(name, null);
|
||||
if (old != null) //only dirty if there was a previous value
|
||||
_dirty=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue