mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -127,16 +127,36 @@ public abstract class AbstractLockDAOImpl implements LockDAO
|
||||
{
|
||||
requiredLock = existingLocksMap.get(requiredLock);
|
||||
// Do an update
|
||||
updateLock(requiredLock, lockToken, timeToLive);
|
||||
try
|
||||
{
|
||||
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
|
||||
{
|
||||
// Create it
|
||||
requiredLock = createLock(
|
||||
requiredLockResourceId,
|
||||
requiredExclusiveLockResourceId,
|
||||
lockToken,
|
||||
timeToLive);
|
||||
try
|
||||
{
|
||||
// Create it
|
||||
requiredLock = createLock(
|
||||
requiredLockResourceId,
|
||||
requiredExclusiveLockResourceId,
|
||||
lockToken,
|
||||
timeToLive);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new LockAcquisitionException(
|
||||
e, // Keep this for possible retrying
|
||||
LockAcquisitionException.ERR_FAILED_TO_ACQUIRE_LOCK,
|
||||
lockQName, lockToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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
|
||||
* well.
|
||||
* Put new values against the given exclusive lock. This works against the related locks as well.
|
||||
* @throws LockAcquisitionException on failure
|
||||
*/
|
||||
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 timeToLive the new lock time, in milliseconds, for the lock to remain valid
|
||||
* @return Returns the updated lock
|
||||
* @throws ConcurrencyFailureException if the entity was not updated
|
||||
*/
|
||||
protected abstract LockEntity updateLock(
|
||||
LockEntity lockEntity,
|
||||
|
@@ -80,7 +80,6 @@ public class LockAcquisitionException extends AlfrescoRuntimeException
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param msgId one of the message IDs defined
|
||||
* @param args the arguments that apply
|
||||
*/
|
||||
@@ -88,4 +87,14 @@ public class LockAcquisitionException extends AlfrescoRuntimeException
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user