You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by KÖLL Claus <C....@TIROL.GV.AT> on 2009/01/15 08:48:59 UTC

locking question

hi @ all

i dont know if it is a bug or "works as designed" but if i try ...

Node n1 = testRootNode.addNode(nodeName1);
n1.addMixin(mixLockable);
n1.addMixin(mixReferenceable);
testRootNode.save();

Lock lock = n1.lock(true, false); /** No session scoped lock !
String lockToken = lock.getLockToken();
String path = n1.getPath();
            
//superuser.logout(); <- only if i logout the session that creates the lock i get no exception !
        
Session otherSuperuser = helper.getSuperuserSession();
otherSuperuser.addLockToken(lockToken);
Node n2 = (Node) otherSuperuser.getItem(path);
n2.unlock();

i get a LockException "Node not locked by session"
as written above ... only if i logout the session that creates the lock i get no exception

i didnt found anything about that in the spec ...
WDOT ?

greets
claus

AW: locking question

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
yes you are right 
i didn't removed the lock token from the original session

thanks for the information ..

greets
claus

-----Ursprüngliche Nachricht-----
Von: Angela Schreiber [mailto:anchela@day.com] 
Gesendet: Donnerstag, 15. Jänner 2009 09:09
An: dev@jackrabbit.apache.org
Betreff: Re: locking question

hi claus

but you didn't remove the lock token from the original
lock owning session, did you?

in this case this is the expected behaviour as defined
by jsr 170: in fact the lock token was not added to
'otherSession' and it didn't became lock holder.
((there is probably a warning in the log)).

if your otherSession wasn't an admin session
you would get an exception irrespective of wether
the original session logged out or not.

this will be addressed with jsr 283 (LockManager.addLockToken
is then defined to throw LockException).

regards
angela


KÖLL Claus wrote:
> hi @ all
> 
> i dont know if it is a bug or "works as designed" but if i try ...
> 
> Node n1 = testRootNode.addNode(nodeName1);
> n1.addMixin(mixLockable);
> n1.addMixin(mixReferenceable);
> testRootNode.save();
> 
> Lock lock = n1.lock(true, false); /** No session scoped lock !
> String lockToken = lock.getLockToken();
> String path = n1.getPath();
>             
> //superuser.logout(); <- only if i logout the session that creates the lock i get no exception !
>         
> Session otherSuperuser = helper.getSuperuserSession();
> otherSuperuser.addLockToken(lockToken);
> Node n2 = (Node) otherSuperuser.getItem(path);
> n2.unlock();
> 
> i get a LockException "Node not locked by session"
> as written above ... only if i logout the session that creates the lock i get no exception
> 
> i didnt found anything about that in the spec ...
> WDOT ?
> 
> greets
> claus
> 


Re: locking question

Posted by Angela Schreiber <an...@day.com>.
hi claus

but you didn't remove the lock token from the original
lock owning session, did you?

in this case this is the expected behaviour as defined
by jsr 170: in fact the lock token was not added to
'otherSession' and it didn't became lock holder.
((there is probably a warning in the log)).

if your otherSession wasn't an admin session
you would get an exception irrespective of wether
the original session logged out or not.

this will be addressed with jsr 283 (LockManager.addLockToken
is then defined to throw LockException).

regards
angela


KÖLL Claus wrote:
> hi @ all
> 
> i dont know if it is a bug or "works as designed" but if i try ...
> 
> Node n1 = testRootNode.addNode(nodeName1);
> n1.addMixin(mixLockable);
> n1.addMixin(mixReferenceable);
> testRootNode.save();
> 
> Lock lock = n1.lock(true, false); /** No session scoped lock !
> String lockToken = lock.getLockToken();
> String path = n1.getPath();
>             
> //superuser.logout(); <- only if i logout the session that creates the lock i get no exception !
>         
> Session otherSuperuser = helper.getSuperuserSession();
> otherSuperuser.addLockToken(lockToken);
> Node n2 = (Node) otherSuperuser.getItem(path);
> n2.unlock();
> 
> i get a LockException "Node not locked by session"
> as written above ... only if i logout the session that creates the lock i get no exception
> 
> i didnt found anything about that in the spec ...
> WDOT ?
> 
> greets
> claus
> 


Re: locking question

Posted by Paco Avila <mo...@gmail.com>.
On Thu, Jan 15, 2009 at 8:48 AM, KÖLL Claus <C....@tirol.gv.at> wrote:
> hi @ all
>
> i dont know if it is a bug or "works as designed" but if i try ...
>
> Node n1 = testRootNode.addNode(nodeName1);
> n1.addMixin(mixLockable);
> n1.addMixin(mixReferenceable);
> testRootNode.save();
>
> Lock lock = n1.lock(true, false); /** No session scoped lock !
> String lockToken = lock.getLockToken();
> String path = n1.getPath();
>
> //superuser.logout(); <- only if i logout the session that creates the lock i get no exception !
>
> Session otherSuperuser = helper.getSuperuserSession();
> otherSuperuser.addLockToken(lockToken);
> Node n2 = (Node) otherSuperuser.getItem(path);
> n2.unlock();
>
> i get a LockException "Node not locked by session"
> as written above ... only if i logout the session that creates the lock i get no exception
>
> i didnt found anything about that in the spec ...
> WDOT ?
>
> greets
> claus
>

The lock token can't be owned by two sessions at the same time.

-- 
Paco Avila
GIT Consultors
tel: +34 971 498310
fax: +34 971496189
e-mail: pavila@git.es
http://www.git.es