|Re: No exceptions when importing an XMI with abstract classes [message #1246737 is a reply to message #1246050]
||Sat, 15 February 2014 11:25
| Ed Merks
Registered: July 2009
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:Product Name="Comstock Plus Feed for Pricing">
> <workflow product="/883" etlGroups="/884 /885 /893" localName="wf">
> <uuid lsb="-7248504380530605623" msb="8991629227544431788"/>
> <edmmodel:ETLGroup name="Request Prices" workflows="/email@example.com">
> 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
> 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.
Professional Support: https://www.macromodeling.com/
Powered by FUDForum
. Page generated in 0.06166 seconds