* Make sure child objects removed via removeChild() are not accessible

anymore from that collection. 
  Fixes bug 551 <http://helma.org/bugs/show_bug.cgi?id=551>
This commit is contained in:
hns 2007-11-20 09:37:39 +00:00
parent ad68ca97b3
commit 9858091c20
3 changed files with 21 additions and 3 deletions

View file

@ -793,7 +793,7 @@ public final class Node implements INode, Serializable {
pn2 = (Node) pn2.getNode(pinfo.collectionname);
} else if (pn2.equals(this)) {
// a special case we want to support: virtualname is actually
// a reference to this node, not a collection containint this node.
// a reference to this node, not a collection containing this node.
setParent(pn);
name = pinfo.virtualname;
anonymous = false;
@ -1376,8 +1376,14 @@ public final class Node implements INode, Serializable {
String propname = (localrel == null) ? prel.accessName : localrel.propName;
String prop = node.getString(propname);
if ((prop != null) && (getNode(prop) == node)) {
unset(prop);
if (prop != null) {
if (getNode(prop) == node) {
unset(prop);
}
// let the node cache know this key's not for this node anymore.
if (state != TRANSIENT) {
nmgr.evictKey(new SyntheticKey(getKey(), prop));
}
}
}
// TODO: We should unset constraints to actually remove subnodes here,

View file

@ -407,6 +407,10 @@ public final class NodeManager {
*/
public void evictKey(Key key) {
cache.remove(key);
// also drop key from thread-local transactor cache
if (Thread.currentThread() instanceof Transactor) {
((Transactor) Thread.currentThread()).dropCleanNode(key);
}
}
////////////////////////////////////////////////////////////////////////

View file

@ -139,6 +139,14 @@ public class Transactor extends Thread {
}
}
/**
* Drop a reference to an unmodified Node previously registered with visitCleanNode().
* @param key the key
*/
public void dropCleanNode(Key key) {
cleanNodes.remove(key);
}
/**
* Get a reference to an unmodified Node local to this transaction
*