Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » No exceptions when importing an XMI with abstract classes
No exceptions when importing an XMI with abstract classes [message #1246050] Fri, 14 February 2014 17:01 Go to next message
Key Ofeka is currently offline Key OfekaFriend
Messages: 14
Registered: January 2011
Junior Member
This is a question about error handling.

Consider this case:

You export your model to an XMI document. At the moment of exporting you have the class Stream

...
<edmmodel:Stream records="/886" name="ComStock Plus request prices" description="Pulls prices from ComStock Plus Feed">
</edmmodel:Stream>
<edmmodel:Product Name="Comstock Plus Feed for Pricing">
<workflow product="/883" etlGroups="/884 /885 /893" localName="wf">
<uuid lsb="-7248504380530605623" msb="8991629227544431788"/>
</workflow>
</edmmodel:Product>
<edmmodel:ETLGroup name="Request Prices" workflows="/883/@workflow.0">
</edmmodel:ETLGroup>
...

In this example the ETLGroup Request Prices references the workflow wf contained by the product Comstock Plus Feed for Pricing

At some point your data model changes and Stream is now abstract class.

If you try importing the old model you will get a totally misleading error message

java.lang.IllegalArgumentException: The feature 'workflow' is not a valid feature

The real cause is that Stream was skipped and ETLGroup is now at the position 883. It hasn't the workflow feature and we see the error.

In my understanding an exception should've been thrown earlier when an abstract element had been encountered.

So, the question to the developers is: why the Stream element is skipped without any error message? Does it really make sense to continue importing the data model if you skip one element and as a result all your positional references now point to wrong elements and attributes?

Re: No exceptions when importing an XMI with abstract classes [message #1246737 is a reply to message #1246050] Sat, 15 February 2014 11:25 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Comments below.

On 14/02/2014 6:01 PM, Key Ofeka wrote:
> This is a question about error handling.
>
> Consider this case:
>
> You export your model to an XMI document. At the moment of exporting
> you have the class Stream
>
> ...
> <edmmodel:Stream records="/886" name="ComStock Plus request prices"
> description="Pulls prices from ComStock Plus Feed">
> </edmmodel:Stream>
> <edmmodel:Product Name="Comstock Plus Feed for Pricing">
> <workflow product="/883" etlGroups="/884 /885 /893" localName="wf">
> <uuid lsb="-7248504380530605623" msb="8991629227544431788"/>
> </workflow>
> </edmmodel:Product>
> <edmmodel:ETLGroup name="Request Prices" workflows="/883/@workflow.0">
> </edmmodel:ETLGroup>
> ...
>
> In this example the ETLGroup Request Prices references the workflow wf
> contained by the product Comstock Plus Feed for Pricing
>
> At some point your data model changes and Stream is now abstract class.
Breaking serializations that expect it to be concrete.
>
> If you try importing the old model you will get a totally misleading
> error message
>
> java.lang.IllegalArgumentException: The feature 'workflow' is not a
> valid feature
>
> The real cause is that Stream was skipped and ETLGroup is now at the
> position 883. It hasn't the workflow feature and we see the error.
Likely if you look in Resource.getErrors you see a bunch of them.
>
> In my understanding an exception should've been thrown earlier when an
> abstract element had been encountered.
An exception for one of the problems is thrown after the whole resource
is processed. No exceptions are thrown during processing, so you should
expect to be able to find all the problems in Resource.getErrors (as
you'll see in the generated editor)...
>
> So, the question to the developers is: why the Stream element is
> skipped without any error message?
I doubt it's skipped without an error message, but only one exception
can be thrown. Have a look what happens in
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors()
> Does it really make sense to continue importing the data model if you
> skip one element and as a result all your positional references now
> point to wrong elements and attributes?
The general behavior is to try to load as much of the resource as
possible and to report all errors found. It would be kind of annoying
if the Java compiler stopped at the first error when it could report 1.
Of course the Java compiler can be smarter about one syntax error not
leading to 10,000 error messages, but the XMI parser doesn't know what
kind of downstream errors can be caused by an initial error. E.g, if
you used XMI IDs, you'd have problems with broken references only for
things referring to the skipped item.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Converting an XMI to XML Resource
Next Topic:An interesting master-detail-scenario
Goto Forum:
  


Current Time: Thu Apr 25 19:10:43 GMT 2024

Powered by FUDForum. Page generated in 0.02765 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top