Systems-Modeling / SysML-v2-Pilot-Implementation

Proof-of-concept pilot implementation of the SysML v2 textual notation and visualization
GNU Lesser General Public License v3.0
131 stars 24 forks source link

ST6RI-762: %viz command causes ConcurrentModificationException #557

Closed himi closed 7 months ago

himi commented 7 months ago

The changes made in PR #552 resulted in uses of the %viz command in the Jupyter environment to sometimes throw a ConcurrentModificationException. This happens when traversing the ownedRelationships of an element. If the traversal enters into a library model, it is possible (after PR #552) that implicit specialization processing will cause the "on demand" insertion of new elements into the abstract syntax tree in a small number of cases (result parameter for an expression, subject for a requirement or case, objective for a case). If this happens, a new ownedRelationship is added (for the membership of the new element), which can cause the ConcurrentModificationException.

This PR resolves the problem by adding utility methods that create arrays for those lists for which direct iteration may be unsafe, and revises the traversal code to use those utilities instead of directly iterating over the unsafe lists.

himi commented 7 months ago

I quickly dealt with your change request. (But I have not checked it well)

himi commented 7 months ago

I think I could make relevant changes. I'll check it further later.

seidewitz commented 7 months ago

I verified that the latest update fixes the bugs in the models in which I had previously found it:

This seems sufficient for the current release.

himi commented 7 months ago

Ed,thank you for the review.