JBoss Cache SVN: r8542 - core/trunk/src/main/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: dereed
Date: 2012-08-02 16:25:22 -0400 (Thu, 02 Aug 2012)
New Revision: 8542
Modified:
core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
Log:
[JBCACHE-1620] Fix race condition when two nodes try to create the same child while locking
Modified: core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2012-08-02 01:30:11 UTC (rev 8541)
+++ core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2012-08-02 20:25:22 UTC (rev 8542)
@@ -146,14 +146,19 @@
// if the new node is to be marked as deleted, do not notify!
PessimisticUnversionedNode parentInternalNode = (PessimisticUnversionedNode) parent.getDelegationTarget();
currentNode = parentInternalNode.addChildAndAcquireLock(childName, !skipNotification, new LockAcquirer(ctx, WRITE, timeout, owner));
- skipLockAcquire = true;
- if (!created)
+
+ //JBCACHE-1620 make sure we created and locked the node, not a different thread
+ if ( currentNode.getLock().isOwner(owner) )
{
- created = true;
- createdLevel = currentIndex;
+ skipLockAcquire = true;
+ if (!created)
+ {
+ created = true;
+ createdLevel = currentIndex;
+ }
+ if (trace) log.trace("Child node was null, so created child node " + childName);
+ if (createdNodes != null) createdNodes.add(currentNode);
}
- if (trace) log.trace("Child node was null, so created child node " + childName);
- if (createdNodes != null) createdNodes.add(currentNode);
}
else
{