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);
|
requiredLock = existingLocksMap.get(requiredLock);
|
||||||
// Do an update
|
// 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
|
else
|
||||||
{
|
{
|
||||||
// Create it
|
try
|
||||||
requiredLock = createLock(
|
{
|
||||||
requiredLockResourceId,
|
// Create it
|
||||||
requiredExclusiveLockResourceId,
|
requiredLock = createLock(
|
||||||
lockToken,
|
requiredLockResourceId,
|
||||||
timeToLive);
|
requiredExclusiveLockResourceId,
|
||||||
|
lockToken,
|
||||||
|
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,
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user