-
1. Re: ItemExistException due to conccurent access ?
hchiorean Feb 2, 2012 4:00 AM (in response to akrambenaissi)1 of 1 people found this helpfulHi,
The exception is caused by the fact that nt:folder (which I'm assuming is the type of MyDir) does not allow SNS. The reason why this happens, is that the multi-threaded code causes the repository to try to add R multiple times to the same parent dir. Using the same JCR session from multiple threads is not thread-safe and could cause this to happen.
-
2. Re: ItemExistException due to conccurent access ?
akrambenaissi Feb 2, 2012 4:21 PM (in response to hchiorean)Hi,
Well, the point is that I am using different sessions for each thread.
-
3. Re: ItemExistException due to conccurent access ?
hchiorean Feb 3, 2012 2:41 AM (in response to akrambenaissi)can you pls post the test case
-
4. Re: ItemExistException due to conccurent access ?
akrambenaissi Mar 8, 2012 5:03 PM (in response to hchiorean)Hi Horia,
Sorry I did not manage to isolate precisely the case. And because it is using threads, it always hard to reproduce.
Anyway, here is the scenario:
I want to create a tree folder, /A/B/C/d :
To do so, I have let's say 3 threads, each thread has its own session and they are launched conccurently.
T1: has to create /A/B/C
T2: has to create /A/B
T3: has to create A
T1 : has to create the d file
I am using the same code as the rest client, and it seems that when a parent folder does not exist it is created.
So what happens if T1 creates A and B and C, when T3 comes to start ?
Hope this could be clearer.
-
5. Re: ItemExistException due to conccurent access ?
hchiorean Mar 9, 2012 4:01 AM (in response to akrambenaissi)In this case, the A nodes (for each thread) would be added as Same Name Siblings under the root node. In effect, this would give you root/A[1], root/A[2], root/A[3], when all 3 threads finish.
Reason for this behavior is that the type of the root node is "mode:root" which allows same name siblings.
So whenever you add multiple children with the same name to a parent (regardless whether multi-threaded or not) the type of the parent is key to whether SNS are allowed or not. If they aren't alllowed, you normally get the exception which you mentioned in the 1st post.