Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 433149 - UML402Resource factory puts dynamic profile definitions in global package registry
Summary: UML402Resource factory puts dynamic profile definitions in global package reg...
Status: VERIFIED FIXED
Alias: None
Product: MDT.UML2
Classification: Modeling
Component: Core (show other bugs)
Version: 5.0.0   Edit
Hardware: All All
: P2 major (vote)
Target Milestone: M7   Edit
Assignee: Christian Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 432737
  Show dependency tree
 
Reported: 2014-04-21 13:48 EDT by Christian Damus CLA
Modified: 2014-04-24 00:24 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Damus CLA 2014-04-21 13:48:11 EDT
Latest UML2 Luna (git master commit 32efbfa)

The factory for the UML402Resource sets the XMLResource.OPTION_EXTENDED_METADATA load option to a particular extended metadata instance, not just Boolean.TRUE.  The UML402UMLExtendedMetaData is initialized by the factory with the global package registry, because it doesn't know the resource set context in which the resource will be loaded, so it cannot use the resource set's local registry (as would be the case when setting this option to Boolean.TRUE, as in the UMLResource factory).

The consequence of this is that the dynamic EPackage definition of a profile that is eventually loaded in the resource set is registered in the global package registry.  Any other model subsequently loaded in another resource set that has the same profile version applied will find that same EPackage instance in the registry and create stereotype applications from its EClasses.  The reason why this is a problem is that now all of the stereotype applications in all models loaded in different resource sets trace back to the same profile in the first resource set.

If the EPackage in question is not the latest definition of the profile, then migration to the current version will only work in the first resource set.  The profile migration API has a check before migrating any stereotype instance that the profile defining it is the same profile that is being re-applied; this is only true in the first resource set that loaded the copy of the profile that was put in the global package registry.
Comment 1 Kenn Hussey CLA 2014-04-21 13:55:02 EDT
Thanks, Christian. I think creating a package registry that’s local to the resource factory (like the other legacy resource factories do) should solve the problem:

EPackage.Registry ePackageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);

Do you agree?
Comment 2 Christian Damus CLA 2014-04-21 13:55:59 EDT
That's exactly the change that makes my new unit tests pass, which I was going to ask you to review.  :-)
Comment 3 Christian Damus CLA 2014-04-21 14:04:25 EDT
Fixed in commit a143d4d.
Comment 4 Kenn Hussey CLA 2014-04-24 00:24:22 EDT
An integration build containing the fix is now available.