Community
Participate
Working Groups
Build Identifier: None of the structures under AbstractArtifact.java are protected against concurrent access. Under ArtifactRenameRequest.java the following code in updateReferences method modifies a Collection while iterating over it. This obviously causes a ConcurrentModificationException, which in turn causes the EMF transaction to fail. Once the transaction fails, EMF tries to rollback the transaction by recovering the old name, hence the renaming is never successful. Note that this only happens with contained artifacts and JRE doesn't always guarantee ConcurrentModificationException to be thrown. ArtifactRenameRequest#updateReferences(): // take care of contained artifacts same way // This is looking DOWNWARDS Collection<IModelComponent> contains = artifact .getContainedModelComponents(); boolean containsChanged = false; for (IModelComponent cont : contains) { if (cont instanceof AbstractArtifact) { AbstractArtifact containedArt = (AbstractArtifact) cont; if (containedArt.getFullyQualifiedName().equals(oldFQN) || containedArt.getFullyQualifiedName().equals( newName)) { aArtifact.removeContainedModelComponent(cont); aArtifact .addContainedModelComponent(referencedArtifact); needSave = false; } } } Reproducible: Always Steps to Reproduce: 1. Create a new class diagram 2. Create two entities with an association between them 3. Double click on the association 4. Rename the association in the edit dialog that pops up and click on OK. If AbstractArtifact is in fact accessed on multiple threads, then we need to protect this class under concurrent access. Otherwise, we can fix the code snippet that I've indicated under Details section.
because all the renames from diagrams should be hooked up with the refactor framework it should be possible to rename an association by clicking on its name. The refactor dialog should pop up. To be verified. Also, as a result of other fix, the "name" box should now be disabled on this dialog. so this should not happen directly anymore. Still this code WILL be called from the initial rename (when DnD from palette), which is worth a fix.
Created attachment 176998 [details] Patch Fixed the ConcurrentModificationException in ArtifactRenameRequest
Submitted patch.