Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 497559 - Unsupported operation exception when saving representations in Sirius 4.0.0 using Xbase
Summary: Unsupported operation exception when saving representations in Sirius 4.0.0 u...
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 4.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.1.2   Edit
Assignee: Pierre-Charles David CLA
QA Contact: Laurent Fasani CLA
URL:
Whiteboard: needtest
Keywords:
: 521343 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-07-08 06:21 EDT by Eirik Grønsund CLA
Modified: 2017-08-24 05:17 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eirik Grønsund CLA 2016-07-08 06:21:11 EDT
As assumed by Pierre-Charles David, the following change in 4.0.0 caused the save operation of representations to fail for Xbase models:

https://git.eclipse.org/r/#/c/64483/

By reverting, considering file and platform resource as savable instead of only "not read-only" resources, the save operation succeeded. 

This just confirms the cause of the unsupported operation exception, but, as I understand it, does not solve the initial problem with read-only resources.

Regards,
Eirik
Comment 1 Pierre-Charles David CLA 2016-07-08 07:46:22 EDT
See also this thread for more details: https://www.eclipse.org/forums/index.php/t/1079002/
Comment 2 Pierre-Charles David CLA 2016-07-08 07:49:46 EDT
The commit which caused the regression was made for bug #483807. Any attempt to fix the regression should take that other ticket's case into account (and not cause a different regression).

Erik: what's the simplest case to reproduce the issue? Can you point to a publicly accessible Xbase-based metamodel that can easily be installed to reproduce and test the issue?
Comment 3 Eirik Grønsund CLA 2016-07-10 11:50:38 EDT
(In reply to Pierre-Charles David from comment #2)
> The commit which caused the regression was made for bug #483807. Any attempt
> to fix the regression should take that other ticket's case into account (and
> not cause a different regression).
> 
> Erik: what's the simplest case to reproduce the issue? Can you point to a
> publicly accessible Xbase-based metamodel that can easily be installed to
> reproduce and test the issue?

I haven't found any out-of-the-box sample for Xbase/Sirius. I created a Xtext project from the "Five simple steps to your JVM language" tutorial and added a minimal specification and representation bundle.

You can clone it from:

https://github.com/eirikg/XbaseSiriusIntegration

I added a readme file at the root of the org.example.domainmodel bundle project.

Hope you can use it to verify the exception.
Comment 4 Maxime Porhel CLA 2016-07-11 08:21:30 EDT
Hi Eirik, 

I forked the XBaseSiriusIntegration project to try to reproduce your issue, and the xtend-gen folder contains only empty packages (with .gitingore) files. 
In order to facilitate the triage of this issue and the future homologation once corrected, could you add a commit on your project with xtend generated code. It will ease the reproduction and reduce the needed steps to use your reproduction data/project. 

Regards
Comment 5 Eirik Grønsund CLA 2016-07-11 17:56:57 EDT
Hi Maxime

Added the generated java files and (.java_trace and .xtendbin) generated by Extend.

In case you were not aware of it, the Xtend builder will generate the java files after a fork when a full build is run. To prevent it you can deactivate the Xtend builder in the preference dialog
Comment 6 Maxime Porhel CLA 2016-07-12 05:25:25 EDT
Thanks Erik, 

I am aware of the Xtend builder, but having the generated code in the repo will ease the reproduction and the homologation of the issue when it will be resolved. The Xtend builder and tooling will not be required to do the validation of the correction.
Comment 7 Zoltan Ujhelyi CLA 2016-11-08 04:49:03 EST
I had the same problem, and I have managed to work it around by updating the XtextSavingPolicy implementation (see commit https://github.com/ujhelyiz/org.eclipse.sirius/commit/a41aafadfce1afd0ef36fee88fcd56ac2c491c84).

This change simply filters all TypeResource instances from the set of saved resources, and thus avoids the entire issue.

If you are interested in this fix, I'd be glad to provide it as a Gerrit change as well or am prepared to update it if something is incorrect with it.
Comment 8 Maxime Porhel CLA 2016-11-08 08:35:13 EST
As shown in [1], calling save on a TypeResource will throw an UnsupportedOperationException:

> @Override
> public void save(Map<?, ?> options) throws IOException {
>  throw new UnsupportedOperationException();
> }

Your fix seems very interesting, do not hesitate to provide it.
However, it will be very specific to this use case: I wonder if we should not also do additional tests in the saving policy to check if we need to ad a guard on resrouce.getUri().isPlatformPlugin().

Regards,

-----

[1] https://github.com/eclipse/xtext-extras/blob/master/org.eclipse.xtext.common.types/src/org/eclipse/xtext/common/types/access/TypeResource.java
Comment 9 Eclipse Genie CLA 2016-11-08 08:39:24 EST
New Gerrit change created: https://git.eclipse.org/r/84664
Comment 10 Zoltan Ujhelyi CLA 2016-11-08 08:46:56 EST
(In reply to Maxime Porhel from comment #8)
> 
> Your fix seems very interesting, do not hesitate to provide it.
> However, it will be very specific to this use case: I wonder if we should
> not also do additional tests in the saving policy to check if we need to ad
> a guard on resrouce.getUri().isPlatformPlugin().

I have pushed the fix to Gerrit (see comment #9)

The platform uri might be also necessary, however I have currently no test case available for that use case. It is possible that it works out of the box, as the read-only check in ResourceSetSync#isReadOnly might detect those element, albeit I am not sure. Regardless, I was not able to set the read only flag this method check correctly, so I opted to simply check for TypeResources.

Furthermore, given that is not Xtext/Xbase-specific, that should target a different SavingPolicy implementation (but I am not sure which one).
Comment 13 Pierre-Charles David CLA 2016-11-24 09:33:49 EST
The fix is merged, thanks Zoltan!

I'm leaving the ticket opened for now with the "needtest" tag, to remember to try to create a non-regression test before we close it. Given that it's Xbase specific, I'm not sure if it will be possible in a reasonable time with our current test infra.
Comment 14 Pierre-Charles David CLA 2016-12-08 11:12:51 EST
Available in Sirius 4.1.2 (see https://wiki.eclipse.org/Sirius/4.1.2 for details).
Comment 15 Karsten Thoms CLA 2017-08-24 05:17:39 EDT
*** Bug 521343 has been marked as a duplicate of this bug. ***