Bug 432737 - Profile Update Not Working
Summary: Profile Update Not Working
Status: VERIFIED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P1 major (vote)
Target Milestone: M7   Edit
Assignee: Christian Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 433149
Blocks:
  Show dependency tree
 
Reported: 2014-04-14 10:02 EDT by Toni Siljamäki CLA
Modified: 2014-04-29 08:11 EDT (History)
2 users (show)

See Also:


Attachments
Screenshots of non-working profile update (103.53 KB, image/jpeg)
2014-04-14 10:02 EDT, Toni Siljamäki CLA
no flags Details
Test cases for profile update that can be reproduced (139.77 KB, application/x-zip-compressed)
2014-04-14 10:19 EDT, Toni Siljamäki CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Toni Siljamäki CLA 2014-04-14 10:02:22 EDT
Created attachment 241961 [details]
Screenshots of non-working profile update

Used version is Papyrus UML 1.0.0.v201404101527.

I planned to test the profile switch but stumbled on this bug first.

Updating the profile for a single model works, but updating subsequent models
without closing the previously updated model does not work.

The model seem to be "half updated" (or something) wrt the version
and content of the updated profile. See screenshot.

*  The profile is updated from version 0.3.3 to version 0.4.1.

*  One thing that happened between these two version is that
   the stereotype NWAArea changed name to NWAFunction.

*  In the Papyrus UI the profile version seem to have been updated to
   version 0.4.1 and the applied stereotype name updated to NWAFunction.

*  ...but in the .uml file the profile version is still 0.3.3 (.../32)
   and the name of the applied stereotype is still NWAArea.

This fatal bug is one reason why the new "cleaning function" proposed in
Bug 431953 should be run both when opening a model and after a profile has
been updated to ensure that the in-memory model of the model is correct before
saving it to file. (perhaps also reload the model from file and check again)

Perhaps this bug is fixed after 1.0.0.v201404101527, but in any case there
should be regression test cases covering this and similar problems.
Comment 1 Toni Siljamäki CLA 2014-04-14 10:19:48 EDT
Created attachment 241963 [details]
Test cases for profile update that can be reproduced

PW for this one sent to Camille.

Attached is a zip with profiles and exported projects containing
before-and-after-profile-update versions of models, plus the
models where the update failed. Example:

* FixedAccess\NWAProfile_version_0.3.3 is the model for profile version 0.3.3.

* FixedAccess\NWAProfile_version_0.4.1 is the model successfully updated for
  version 0.4.1 of the profile, when opening, updating, saving and
  closing the models one by one.

* FixedAccess is the model described in the attached slide.

The tests can be run again by manually copying the models under
NWAProfile_version_0.3.3 to one level above and refreshing the projects.

Then open the models to update to the 0.4.1 version of the profile and
then save to disk, one by one, without closing the already updated models.
Comment 2 Christian Damus CLA 2014-04-14 12:06:15 EDT
Trying to reproduce this on a simple profile applied to a couple of models, I see both models correctly migrated with the stereotype name change recognized and the correct Ecore definition applied and instantiated.

However, I did get exceptions in the unloading of the affected models before they were re-loaded for migration.  Those are reported as bug 432753.  Perhaps some exception (thinking especially of a ConcurrentModificationException) bombs the profile re-apply procedure?  That could explain the symptoms observed by the reporter.

Are there any exceptions in the workspace log that could illuminate the issue?
Comment 3 Toni Siljamäki CLA 2014-04-15 07:38:57 EDT
Which Papyrus version are you using?
Apparently you have updated the UML2 component too.
Comment 4 Toni Siljamäki CLA 2014-04-15 07:39:37 EDT
Have you tried the attached test case?
Comment 5 Christian Damus CLA 2014-04-21 09:56:07 EDT
I have reproduced the problem on current Git master (commit 31208d4) in more than one of the models attached by the reporter.  I'll investigate the cause.  The error log reports no exceptions.
Comment 6 Christian Damus CLA 2014-04-21 11:57:34 EDT
The problem is that the models manifesting this profile migration issue were created before Papyrus adopted the UML 2.5 implementation of the UML2 project, which is why I didn't reproduce it in my own experiment.  These models (UML 2.4.1 schema) are loaded using UML2's UML402Resource implementation, not the UMLResource which supports UML 2.5 instances.

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 case).

The consequence of this is that the dynamic EPackage definition of the profile (the 0.3.3 version) that is eventually loaded in the resource set is registered in the global package registry.  Not good!  Any other model subsequently loaded 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 all editors trace back to the same profile in the first editor that was opened.  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 editor that was opened.  So, none of the other editors actually migrates any stereotype applications because the API thinks they are defined by a different profile.

To fix this, we may perhaps somehow ensure that the resource set's local package registry is injected into the UML402UMLExtendedMetaData.  But, in any case, it's a bug in UML2 that  the resource factory creates an extended metadata instance in the first place, because UML2 should know that profiles may be loaded that have dynamic EPackages that should never be added to the global package registry.
Comment 7 Christian Damus CLA 2014-04-21 14:21:30 EDT
A fix for the UML2 bug 433149 has been pushed and will be available in the next UML2 integration build.  The current bug can be resolved when that UML2 build is integrated into the Papyrus build.
Comment 8 Christian Damus CLA 2014-04-24 13:31:40 EDT
The UML2 project has published an integration build with the fix for bug 433149, and it is now picked up by the Papyrus nightly builds.
Comment 9 Toni Siljamäki CLA 2014-04-29 06:44:15 EDT
Tested using

Papyrus UML 1.0.0.v201404290454
UML2 Extender SDK 5.0.0.v20140424-0004

and it seems to work fine. :)
The model gets "repaired" when opened and the stereotype in the 0.3.3 version
of the profile is migrated to the renamed stereotype in the 0.4.1 version.

Great job!
Comment 10 Christian Damus CLA 2014-04-29 08:02:48 EDT
(In reply to Toni Siljamäki from comment #9)
> 
> Great job!

Thanks for the verification! Please do keep report any further issues in this area; it has turned out more complicated than I had first thought it should.
Comment 11 Toni Siljamäki CLA 2014-04-29 08:11:04 EDT
The mismatch between what the Papurus UI said wrt profile version and
stereotype name was found only "by accident" while doing some archeological
investigations of the .uml file content.

...not something you do just for the fun of it. :(

But we keep our eyes open, of course, and I guess your new "cleaning"
function can detect things not found during regression tests.