opensourceBIM / BIMserver

The open source BIMserver platform
GNU Affero General Public License v3.0
1.54k stars 608 forks source link

ConcurrentModificationException while iterating over indexPerClassWithSubTypes #786

Open hlg opened 6 years ago

hlg commented 6 years ago

This is not actually an issue, but a question:

I am using the Java client to access BIMserver iterate over the List retrieved via ClientModel.getAllWithSubTypes. During this iteration, I get a ConcurrentModificationException.

I could narrow down one case to having IdEObject with state TO_BE_LOADED in the model retrieved in lazy loading mode (deep=false). Once I hit one of those objects during the iteration, they are loaded and added to the list. When I use deep loading, this exception does not appear. But another case keeps failing with deep loading. I am trying to isolate this case and post a small example.

Can I assume that the index of the initial list is stable and newly loaded entities are added to the end only? That is can I use the index to iterate over the original part of the list or do I have to copy the list before iteration?

hlg commented 6 years ago

I gave up to investigate the deep loading case for now, because the model is too large. I am using lazy loading, but do not really understand why and where the indexPerClassWithSubTypes list is modified. My gut feeling is that it should not change just because the state of one of its members changes.

rubendel commented 6 years ago

Sorry for the late reply. Yes I think you are right, to be honest this code needs to be refactored. I would like to get rid of the EMF model on the server and only use it on the client (and then the server can use the client), so we can simplify things. Unfortunately there are so many other projects going on at the moment that I don't have time to to work on this now.