Do not set write locks when adding a node or setting a node to a
transient parent.
This commit is contained in:
parent
7a95ff731b
commit
be1dd61a19
1 changed files with 23 additions and 16 deletions
|
@ -737,16 +737,19 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
public INode addNode (INode elem, int where) {
|
public INode addNode (INode elem, int where) {
|
||||||
|
|
||||||
Node node = null;
|
Node node = null;
|
||||||
if (elem instanceof Node)
|
if (elem instanceof Node)
|
||||||
node = (Node) elem;
|
node = (Node) elem;
|
||||||
else
|
else
|
||||||
throw new RuntimeException ("Can't add fixed-transient node to a persistent node");
|
throw new RuntimeException ("Can't add fixed-transient node to a persistent node");
|
||||||
|
|
||||||
// only lock node if it has to be modified for a change in subnodes
|
// only lock nodes if parent node is not transient
|
||||||
if (!ignoreSubnodeChange ())
|
if (state != TRANSIENT) {
|
||||||
checkWriteLock ();
|
// only lock parent if it has to be modified for a change in subnodes
|
||||||
node.checkWriteLock ();
|
if (!ignoreSubnodeChange ())
|
||||||
|
checkWriteLock ();
|
||||||
|
node.checkWriteLock ();
|
||||||
|
}
|
||||||
|
|
||||||
// if subnodes are defined via realation, make sure its constraints are enforced.
|
// if subnodes are defined via realation, make sure its constraints are enforced.
|
||||||
if (dbmap != null && dbmap.getSubnodeRelation () != null)
|
if (dbmap != null && dbmap.getSubnodeRelation () != null)
|
||||||
|
@ -1640,10 +1643,11 @@ public final class Node implements INode, Serializable {
|
||||||
throw new RuntimeException ("Can't set "+propname+" to object with prototype "+value.getPrototype()+", was expecting "+nmap.getTypeName());
|
throw new RuntimeException ("Can't set "+propname+" to object with prototype "+value.getPrototype()+", was expecting "+nmap.getTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
checkWriteLock ();
|
if (state != TRANSIENT)
|
||||||
|
checkWriteLock ();
|
||||||
|
|
||||||
Node n = null;
|
Node n = null;
|
||||||
if (value instanceof Node)
|
if (value instanceof Node)
|
||||||
n = (Node) value;
|
n = (Node) value;
|
||||||
else
|
else
|
||||||
throw new RuntimeException ("Can't add fixed-transient node to a persistent node");
|
throw new RuntimeException ("Can't add fixed-transient node to a persistent node");
|
||||||
|
@ -1652,7 +1656,8 @@ public final class Node implements INode, Serializable {
|
||||||
if (state != TRANSIENT && n.state == TRANSIENT)
|
if (state != TRANSIENT && n.state == TRANSIENT)
|
||||||
n.makePersistentCapable ();
|
n.makePersistentCapable ();
|
||||||
|
|
||||||
n.checkWriteLock ();
|
if (state != TRANSIENT)
|
||||||
|
n.checkWriteLock ();
|
||||||
|
|
||||||
// check if the main identity of this node is as a named property
|
// check if the main identity of this node is as a named property
|
||||||
// or as an anonymous node in a collection
|
// or as an anonymous node in a collection
|
||||||
|
@ -1700,10 +1705,12 @@ public final class Node implements INode, Serializable {
|
||||||
// this is done anyway when the node becomes persistent.
|
// this is done anyway when the node becomes persistent.
|
||||||
if (n.state != TRANSIENT) {
|
if (n.state != TRANSIENT) {
|
||||||
// check node in with transactor cache
|
// check node in with transactor cache
|
||||||
String nID = n.getID();
|
// String nID = n.getID();
|
||||||
DbMapping dbm = n.getDbMapping ();
|
// DbMapping dbm = n.getDbMapping ();
|
||||||
Transactor tx = (Transactor) Thread.currentThread ();
|
Transactor tx = (Transactor) Thread.currentThread ();
|
||||||
tx.visitCleanNode (new DbKey (dbm, nID), n);
|
// tx.visitCleanNode (new DbKey (dbm, nID), n);
|
||||||
|
// UPDATE: using n.getKey() instead of manually constructing key. HW 2002/09/13
|
||||||
|
tx.visitCleanNode (n.getKey(), n);
|
||||||
// if the field is not the primary key of the property, also register it
|
// if the field is not the primary key of the property, also register it
|
||||||
if (rel != null && rel.accessor != null && state != TRANSIENT) {
|
if (rel != null && rel.accessor != null && state != TRANSIENT) {
|
||||||
Key secKey = new SyntheticKey (getKey (), propname);
|
Key secKey = new SyntheticKey (getKey (), propname);
|
||||||
|
|
Loading…
Add table
Reference in a new issue