jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Delia Fernandez <dfernan...@fidesol.org>
Subject Problems with threads modifying properties
Date Thu, 26 Apr 2007 09:29:15 GMT

I'm new to Jackrabbit and have a couple of questions about threading over the
same Repository:

- While reading jsr-170 specification (as introduction to Jackrabbit) I
found this paragraph explaining thread-safety requirements:
 "A content repository implementation is not required to provide thread-safe
implementations of other interfaces. As a consequence, an application which
concurrently or sequentially operates against objects having affinity to a
particular Session through more than one thread must provide synchronization
sufficient to ensure no more than one thread concurrently operates against
that Session and changes made by one thread are visible to other threads." 

I tried to test it with several threads sharing the same code. If each one
of the threads logs on a different session and includes synchronization
parameters as follows:

[...]
synchronized(this){
     Session session=repository.login(new
SimpleCredentials("user","pass".toCharArray());
     Node node=session.getRootNode.getNode("node_to_modify");
     node.setProperty("jcr:data","new data");
     session.save();
     session.logout();
}
[...]

The first thread achieves to modify the property successfully, while the
others just get the following error:

0186c41e-7d73-4b5a-9e45-3990cc7c5597/{http://www.jcp.org/jcr/1.0}data has
been modified externally

How could I modify the values over the same node without errors?
and, if the answer to the previous question is "locking the node", what's
the correct sequence to do it?


-- 
View this message in context: http://www.nabble.com/Problems-with-threads-modifying-properties-tf3650545.html#a10197087
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message