LockDAOTest: Add additional concurrency check to handle test running against clean repo

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29290 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-07-25 08:23:26 +00:00
parent 1546669ade
commit 18a50d8532
2 changed files with 39 additions and 10 deletions

View File

@@ -127,9 +127,21 @@ public abstract class AbstractLockDAOImpl implements LockDAO
{ {
requiredLock = existingLocksMap.get(requiredLock); requiredLock = existingLocksMap.get(requiredLock);
// Do an update // Do an update
try
{
updateLock(requiredLock, lockToken, timeToLive); updateLock(requiredLock, lockToken, timeToLive);
} }
catch (Throwable e)
{
throw new LockAcquisitionException(
e, // Keep this for possible retrying
LockAcquisitionException.ERR_FAILED_TO_ACQUIRE_LOCK,
lockQName, lockToken);
}
}
else else
{
try
{ {
// Create it // Create it
requiredLock = createLock( requiredLock = createLock(
@@ -138,6 +150,14 @@ public abstract class AbstractLockDAOImpl implements LockDAO
lockToken, lockToken,
timeToLive); timeToLive);
} }
catch (Throwable e)
{
throw new LockAcquisitionException(
e, // Keep this for possible retrying
LockAcquisitionException.ERR_FAILED_TO_ACQUIRE_LOCK,
lockQName, lockToken);
}
}
} }
// Done // Done
} }
@@ -153,8 +173,7 @@ public abstract class AbstractLockDAOImpl implements LockDAO
} }
/** /**
* Put new values against the given exclusive lock. This works against the related locks as * Put new values against the given exclusive lock. This works against the related locks as well.
* well.
* @throws LockAcquisitionException on failure * @throws LockAcquisitionException on failure
*/ */
private void updateLocks(QName lockQName, String lockToken, String newLockToken, long timeToLive) private void updateLocks(QName lockQName, String lockToken, String newLockToken, long timeToLive)
@@ -305,6 +324,7 @@ public abstract class AbstractLockDAOImpl implements LockDAO
* @param lockApplicant the new lock token * @param lockApplicant the new lock token
* @param timeToLive the new lock time, in milliseconds, for the lock to remain valid * @param timeToLive the new lock time, in milliseconds, for the lock to remain valid
* @return Returns the updated lock * @return Returns the updated lock
* @throws ConcurrencyFailureException if the entity was not updated
*/ */
protected abstract LockEntity updateLock( protected abstract LockEntity updateLock(
LockEntity lockEntity, LockEntity lockEntity,

View File

@@ -80,7 +80,6 @@ public class LockAcquisitionException extends AlfrescoRuntimeException
} }
/** /**
*
* @param msgId one of the message IDs defined * @param msgId one of the message IDs defined
* @param args the arguments that apply * @param args the arguments that apply
*/ */
@@ -88,4 +87,14 @@ public class LockAcquisitionException extends AlfrescoRuntimeException
{ {
super(msgId, args); super(msgId, args);
} }
/**
* @param cause an exception leading up to this
* @param msgId one of the message IDs defined
* @param args the arguments that apply
*/
public LockAcquisitionException(Throwable cause, String msgId, Object ... args)
{
super(msgId, args, cause);
}
} }