Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Transaction] ConcurrentModificationException while unloading a resource
[EMF Transaction] ConcurrentModificationException while unloading a resource [message #92449] Thu, 02 August 2007 15:18 Go to next message
Sascha Theves is currently offline Sascha ThevesFriend
Messages: 39
Registered: July 2009
Member
Hi all,

we get sometimes ConcurrentModificationExceptions when we are about to
unload/load an EMF resource. Thats because a Thread iterates over the
resources in our common ResourceSet (we only have one) and another Thread
loads a resource - for example. We have written a thread-safe class that
does all the load and unload operations and all other components have to use
that class. This works now but it does not cover the following issue:

One Thread unloads a resource. Another Thread reads the model from the
resource that is being unloaded. These two Threads are not synchronized and
we get several Exceptions.

Our idea is now to use EMF Transaction and there, the READ/WRITE lock
mechanism to prevent these problems. But we are not sure if it is a good
idea to put the load/unload operations in the WRITE lock. Is there another
way to prevent these multithreading issues? Is the approach with EMF
Transaction necessary in load/unload operations? Is our approach with the
thread-safe class a better idea?

For testing purposes we have written several commands which
loading/unloading an EMF resource. These commands are executed in
CommandStack of the TransactionalEditingDomain.
But now we get sometimes a ConcurrentModificationException at
org.eclipse.emf.transaction.impl.ReadWriteValidatorImpl$Noti ficationTree.collectNotifications(ReadWriteValidatorImpl.jav a:405).
Means that unloading/loading of an EMF resource should not be done within a
command?

Thanks in advance

Sascha
Re: [EMF Transaction] ConcurrentModificationException while unloading a resource [message #92465 is a reply to message #92449] Thu, 02 August 2007 18:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Sascha,

I answered some of your more general questions on the EMF newsgroup, where
EMF Transaction now lives.

Regarding the concurrent modification in the ReadWriteValidatorImpl: that
shouldn't happen, so it is probably a bug. If you can provide a
reproducible test case on a bugzilla, that would be great.

In general, loading and unloading resources isn't something that you would
do in a command on the CommandStack, because commands should modify the
model content (what I call "abstract changes") and not just
bookkeeping/metadata objects such as Resources (what I call "concrete
changes"). However, I doubt that this would be the cause of the exception.

Cheers,

Christian

Sascha Theves wrote:

> Hi all,
>
> we get sometimes ConcurrentModificationExceptions when we are about to
> unload/load an EMF resource. Thats because a Thread iterates over the
> resources in our common ResourceSet (we only have one) and another Thread
> loads a resource - for example. We have written a thread-safe class that
> does all the load and unload operations and all other components have to
> use that class. This works now but it does not cover the following issue:
>
> One Thread unloads a resource. Another Thread reads the model from the
> resource that is being unloaded. These two Threads are not synchronized
> and we get several Exceptions.
>
> Our idea is now to use EMF Transaction and there, the READ/WRITE lock
> mechanism to prevent these problems. But we are not sure if it is a good
> idea to put the load/unload operations in the WRITE lock. Is there another
> way to prevent these multithreading issues? Is the approach with EMF
> Transaction necessary in load/unload operations? Is our approach with the
> thread-safe class a better idea?
>
> For testing purposes we have written several commands which
> loading/unloading an EMF resource. These commands are executed in
> CommandStack of the TransactionalEditingDomain.
> But now we get sometimes a ConcurrentModificationException at
>
org.eclipse.emf.transaction.impl.ReadWriteValidatorImpl$Noti ficationTree.collectNotifications(ReadWriteValidatorImpl.jav a:405).
> Means that unloading/loading of an EMF resource should not be done within
> a command?
>
> Thanks in advance
>
> Sascha
Re: [EMF Transaction] ConcurrentModificationException while unloading a resource [message #92568 is a reply to message #92465] Fri, 03 August 2007 12:35 Go to previous message
Sascha Theves is currently offline Sascha ThevesFriend
Messages: 39
Registered: July 2009
Member
Hi Christian,

thanks for the answer. I put all load/unload Operations in the Read-Lock
(with runExclusive(...)). It seems that this works fine. The
ConcurrentModificationException is gone. I can try to reproduce the
ConcurrentModificationException in a test case and report it on bugzilla.
Thanks for your help!

Sascha


"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:f8t9c0$6su$3@build.eclipse.org...
> Hi, Sascha,
>
> I answered some of your more general questions on the EMF newsgroup, where
> EMF Transaction now lives.
>
> Regarding the concurrent modification in the ReadWriteValidatorImpl: that
> shouldn't happen, so it is probably a bug. If you can provide a
> reproducible test case on a bugzilla, that would be great.
>
> In general, loading and unloading resources isn't something that you would
> do in a command on the CommandStack, because commands should modify the
> model content (what I call "abstract changes") and not just
> bookkeeping/metadata objects such as Resources (what I call "concrete
> changes"). However, I doubt that this would be the cause of the
> exception.
>
> Cheers,
>
> Christian
>
> Sascha Theves wrote:
>
>> Hi all,
>>
>> we get sometimes ConcurrentModificationExceptions when we are about to
>> unload/load an EMF resource. Thats because a Thread iterates over the
>> resources in our common ResourceSet (we only have one) and another Thread
>> loads a resource - for example. We have written a thread-safe class that
>> does all the load and unload operations and all other components have to
>> use that class. This works now but it does not cover the following issue:
>>
>> One Thread unloads a resource. Another Thread reads the model from the
>> resource that is being unloaded. These two Threads are not synchronized
>> and we get several Exceptions.
>>
>> Our idea is now to use EMF Transaction and there, the READ/WRITE lock
>> mechanism to prevent these problems. But we are not sure if it is a good
>> idea to put the load/unload operations in the WRITE lock. Is there
>> another
>> way to prevent these multithreading issues? Is the approach with EMF
>> Transaction necessary in load/unload operations? Is our approach with the
>> thread-safe class a better idea?
>>
>> For testing purposes we have written several commands which
>> loading/unloading an EMF resource. These commands are executed in
>> CommandStack of the TransactionalEditingDomain.
>> But now we get sometimes a ConcurrentModificationException at
>>
> org.eclipse.emf.transaction.impl.ReadWriteValidatorImpl$Noti ficationTree.collectNotifications(ReadWriteValidatorImpl.jav a:405).
>> Means that unloading/loading of an EMF resource should not be done within
>> a command?
>>
>> Thanks in advance
>>
>> Sascha
>
Re: [EMF Transaction] ConcurrentModificationException while unloading a resource [message #609415 is a reply to message #92449] Thu, 02 August 2007 18:56 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Sascha,

I answered some of your more general questions on the EMF newsgroup, where
EMF Transaction now lives.

Regarding the concurrent modification in the ReadWriteValidatorImpl: that
shouldn't happen, so it is probably a bug. If you can provide a
reproducible test case on a bugzilla, that would be great.

In general, loading and unloading resources isn't something that you would
do in a command on the CommandStack, because commands should modify the
model content (what I call "abstract changes") and not just
bookkeeping/metadata objects such as Resources (what I call "concrete
changes"). However, I doubt that this would be the cause of the exception.

Cheers,

Christian

Sascha Theves wrote:

> Hi all,
>
> we get sometimes ConcurrentModificationExceptions when we are about to
> unload/load an EMF resource. Thats because a Thread iterates over the
> resources in our common ResourceSet (we only have one) and another Thread
> loads a resource - for example. We have written a thread-safe class that
> does all the load and unload operations and all other components have to
> use that class. This works now but it does not cover the following issue:
>
> One Thread unloads a resource. Another Thread reads the model from the
> resource that is being unloaded. These two Threads are not synchronized
> and we get several Exceptions.
>
> Our idea is now to use EMF Transaction and there, the READ/WRITE lock
> mechanism to prevent these problems. But we are not sure if it is a good
> idea to put the load/unload operations in the WRITE lock. Is there another
> way to prevent these multithreading issues? Is the approach with EMF
> Transaction necessary in load/unload operations? Is our approach with the
> thread-safe class a better idea?
>
> For testing purposes we have written several commands which
> loading/unloading an EMF resource. These commands are executed in
> CommandStack of the TransactionalEditingDomain.
> But now we get sometimes a ConcurrentModificationException at
>
org.eclipse.emf.transaction.impl.ReadWriteValidatorImpl$Noti ficationTree.collectNotifications(ReadWriteValidatorImpl.jav a:405).
> Means that unloading/loading of an EMF resource should not be done within
> a command?
>
> Thanks in advance
>
> Sascha
Re: [EMF Transaction] ConcurrentModificationException while unloading a resource [message #609422 is a reply to message #92465] Fri, 03 August 2007 12:35 Go to previous message
Sascha Theves is currently offline Sascha ThevesFriend
Messages: 39
Registered: July 2009
Member
Hi Christian,

thanks for the answer. I put all load/unload Operations in the Read-Lock
(with runExclusive(...)). It seems that this works fine. The
ConcurrentModificationException is gone. I can try to reproduce the
ConcurrentModificationException in a test case and report it on bugzilla.
Thanks for your help!

Sascha


"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:f8t9c0$6su$3@build.eclipse.org...
> Hi, Sascha,
>
> I answered some of your more general questions on the EMF newsgroup, where
> EMF Transaction now lives.
>
> Regarding the concurrent modification in the ReadWriteValidatorImpl: that
> shouldn't happen, so it is probably a bug. If you can provide a
> reproducible test case on a bugzilla, that would be great.
>
> In general, loading and unloading resources isn't something that you would
> do in a command on the CommandStack, because commands should modify the
> model content (what I call "abstract changes") and not just
> bookkeeping/metadata objects such as Resources (what I call "concrete
> changes"). However, I doubt that this would be the cause of the
> exception.
>
> Cheers,
>
> Christian
>
> Sascha Theves wrote:
>
>> Hi all,
>>
>> we get sometimes ConcurrentModificationExceptions when we are about to
>> unload/load an EMF resource. Thats because a Thread iterates over the
>> resources in our common ResourceSet (we only have one) and another Thread
>> loads a resource - for example. We have written a thread-safe class that
>> does all the load and unload operations and all other components have to
>> use that class. This works now but it does not cover the following issue:
>>
>> One Thread unloads a resource. Another Thread reads the model from the
>> resource that is being unloaded. These two Threads are not synchronized
>> and we get several Exceptions.
>>
>> Our idea is now to use EMF Transaction and there, the READ/WRITE lock
>> mechanism to prevent these problems. But we are not sure if it is a good
>> idea to put the load/unload operations in the WRITE lock. Is there
>> another
>> way to prevent these multithreading issues? Is the approach with EMF
>> Transaction necessary in load/unload operations? Is our approach with the
>> thread-safe class a better idea?
>>
>> For testing purposes we have written several commands which
>> loading/unloading an EMF resource. These commands are executed in
>> CommandStack of the TransactionalEditingDomain.
>> But now we get sometimes a ConcurrentModificationException at
>>
> org.eclipse.emf.transaction.impl.ReadWriteValidatorImpl$Noti ficationTree.collectNotifications(ReadWriteValidatorImpl.jav a:405).
>> Means that unloading/loading of an EMF resource should not be done within
>> a command?
>>
>> Thanks in advance
>>
>> Sascha
>
Previous Topic:Incompatible type requested for parameter field (emf+teneo+jpox)
Next Topic:JPA Annotation for Composite Foregin Key
Goto Forum:
  


Current Time: Fri Aug 12 10:02:45 GMT 2022

Powered by FUDForum. Page generated in 0.02234 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top