> Hi,
>
> I want use the isLocked() and checkLock() method from the Lock class
> (slide 1.0.10).
> But if the parameter from the isLocked() method tryToLock is false the
> return value from the
> isLocked method is also false but the element is locked.
> If the parameter tryToLock=true the result is true -> OK.
> The method checkLock() use the method isLocked() with the parameter
> tryToLock=false, so
> the checkLock() also don't work.
>
> Here my test code:
>
> Date expirationDate = new Date((new Date()).getTime() + 10000000);
> NodeLock nodeLock = new NodeLock("/test/test2", "/users/root",
> "/actions/write", expirationDate, false);
> lock.lock(slideToken, nodeLock);
> System.out.println("/test/test2 isLocked=" + lock.isLocked(slideToken,
> nodeLock, false));
>
> --> the output is:
>
> /test/test2 isLocked=false
>
>
> What is the solution ?

If tryToLock is false, the method will return true if attempting to perform
the specified action on the specified subject (through one of the API
methods) would result in an ObjectLockedException being thrown.
If tryToLock is true, it will return false if you can attempt to lock the
subject. Using isLocked with tryToLock to true and the lock set to exclusive
should be a good test to determine if there is a lock on the object (since
apparently that's what you want to do here).

Remy

Reply via email to