jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Nuescheler" <david.nuesche...@gmail.com>
Subject Re: Problems with threads modifying properties
Date Thu, 26 Apr 2007 10:40:37 GMT
hi delia,

from the code snippet you submitted i can only assume that "this" is probably
the thread you are running in.

if that's the case then synchronizing on (this) doesn't do much, a quick
fix for your testcode could be something like synchronized(this.getClass()).

anyway, the statement you quoted from the specification is with
respect to sharing
a session between multiple threads which is something that you are not even
attempting to do as far as i can tell.


On 4/26/07, Delia Fernandez <dfernandez@fidesol.org> wrote:
> 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.

View raw message