Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Bug in error handling causes misleading LegacyModeNotEnabledException
[CDO] Bug in error handling causes misleading LegacyModeNotEnabledException [message #915628] Mon, 17 September 2012 16:58 Go to next message
Warwick Burrows is currently offline Warwick Burrows
Messages: 87
Registered: July 2009
Location: Austin, TX
Member
Hi CDO team,

I ran into a problem where my previously working model was getting a "Legacy mode is not enabled" message like the following:

Caused by: org.eclipse.emf.cdo.util.LegacyModeNotEnabledException: Legacy mode is not enabled
    at org.eclipse.emf.spi.cdo.FSMUtil.adapt(FSMUtil.java:101)
    at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.getRevision(OCLQueryHandler.java:204)
    at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.addResult(OCLQueryHandler.java:195)
    at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.executeQuery(OCLQueryHandler.java:175)
    ... 7 more


I found that the problem was not due to problems with my objects but due to the mishandling of an error object coming back from an OCL call which was being passed on for further processing as a model object. Here is the code I believe to be in error:

      Object result = evaluate(query, object);
      if (result instanceof Collection<?>)
      {
        for (Object element : (Collection<?>)result)
        {
          if (!addResult(element, context, view))
          {
            break;
          }
        }
      }
      else
      {
        addResult(result, context, view);
      }
    }


The result coming back from evaluate() is an OclInvalid object -- signifying that the evaluation failed -- and since the object isn't an instance of a collection it is passed to the addResult() method. FSMUtil then tries to adapt the object in order to get its revision history which fails with the LegacyModeNotEnabled exception since OclInvalid isnt in the model. Ideally the code should be checking for any of the OclStandardLibrary error objects and returning the error information to the caller.

Should I open a bugzilla defect for this?

Thanks,
Warwick
Re: [CDO/OCL] Bug in error handling causes misleading LegacyModeNotEnabledException [message #915862 is a reply to message #915628] Tue, 18 September 2012 05:18 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5525
Registered: July 2009
Senior Member
Am 17.09.2012 18:58, schrieb Warwick Burrows:
> Hi CDO team,
>
> I ran into a problem where my previously working model was getting a "Legacy mode is not enabled" message like the
> following:
>
> Caused by: org.eclipse.emf.cdo.util.LegacyModeNotEnabledException: Legacy mode is not enabled
> at org.eclipse.emf.spi.cdo.FSMUtil.adapt(FSMUtil.java:101)
> at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.getRevision(OCLQueryHandler.java:204)
> at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.addResult(OCLQueryHandler.java:195)
> at org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.executeQuery(OCLQueryHandler.java:175)
> ... 7 more
>
>
> I found that the problem was not due to problems with my objects but due to the mishandling of an error object coming
> back from an OCL call which was being passed on for further processing as a model object. Here is the code I believe
> to be in error:
>
>
> Object result = evaluate(query, object);
> if (result instanceof Collection<?>)
> {
> for (Object element : (Collection<?>)result)
> {
> if (!addResult(element, context, view))
> {
> break;
> }
> }
> }
> else
> {
> addResult(result, context, view);
> }
> }
>
>
> The result coming back from evaluate() is an OclInvalid object -- signifying that the evaluation failed -- and since
> the object isn't an instance of a collection it is passed to the addResult() method. FSMUtil then tries to adapt the
> object in order to get its revision history which fails with the LegacyModeNotEnabled exception since OclInvalid isnt
> in the model. Ideally the code should be checking for any of the OclStandardLibrary error objects and returning the
> error information to the caller.
>
> Should I open a bugzilla defect for this?
Strange that this didn't pop up earlier. Yes, please submit a bugzilla against EMF/cdo.core.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO/OCL] Bug in error handling causes misleading LegacyModeNotEnabledException [message #915932 is a reply to message #915862] Tue, 18 September 2012 08:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi Eike

This seems remarkably adjacent to existing issues.

From an OCL perspective it is not clear that the OclInvalid result is
not a 'valid' result that should propagate back to the caller. Certainly
invalid is a defined OCL result.

This issue may have further ramifications if/when OCL acquires a
constructor syntax that supports object creation; such objects would
also not be in the model.

And on further reflection an OCL query involving Collection.product may
return a Tuple which is also an object that is not in the model.

So I think the problem is to do with passing OCL returns back to the
caller rather than with the OCL returns themselves.

Regards

Ed Willink

On 18/09/2012 06:18, Eike Stepper wrote:
> Am 17.09.2012 18:58, schrieb Warwick Burrows:
>> Hi CDO team,
>>
>> I ran into a problem where my previously working model was getting a
>> "Legacy mode is not enabled" message like the following:
>>
>> Caused by: org.eclipse.emf.cdo.util.LegacyModeNotEnabledException:
>> Legacy mode is not enabled
>> at org.eclipse.emf.spi.cdo.FSMUtil.adapt(FSMUtil.java:101)
>> at
>> org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.getRevision(OCLQueryHandler.java:204)
>> at
>> org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.addResult(OCLQueryHandler.java:195)
>> at
>> org.eclipse.emf.cdo.server.ocl.OCLQueryHandler.executeQuery(OCLQueryHandler.java:175)
>> ... 7 more
>>
>>
>> I found that the problem was not due to problems with my objects but
>> due to the mishandling of an error object coming back from an OCL
>> call which was being passed on for further processing as a model
>> object. Here is the code I believe to be in error:
>>
>>
>> Object result = evaluate(query, object);
>> if (result instanceof Collection<?>)
>> {
>> for (Object element : (Collection<?>)result)
>> {
>> if (!addResult(element, context, view))
>> {
>> break;
>> }
>> }
>> }
>> else
>> {
>> addResult(result, context, view);
>> }
>> }
>>
>>
>> The result coming back from evaluate() is an OclInvalid object --
>> signifying that the evaluation failed -- and since the object isn't
>> an instance of a collection it is passed to the addResult() method.
>> FSMUtil then tries to adapt the object in order to get its revision
>> history which fails with the LegacyModeNotEnabled exception since
>> OclInvalid isnt in the model. Ideally the code should be checking for
>> any of the OclStandardLibrary error objects and returning the error
>> information to the caller.
>>
>> Should I open a bugzilla defect for this?
> Strange that this didn't pop up earlier. Yes, please submit a bugzilla
> against EMF/cdo.core.
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
Re: [CDO/OCL] Bug in error handling causes misleading LegacyModeNotEnabledException [message #916147 is a reply to message #915932] Tue, 18 September 2012 16:02 Go to previous messageGo to next message
Warwick Burrows is currently offline Warwick Burrows
Messages: 87
Registered: July 2009
Location: Austin, TX
Member
That's what I was thinking too Ed. OCLQueryHandler.executeQuery() needs to detect the failure, log the OCL invalid object contents and fail the call.

Thanks Eike, I'll open a bugzilla.
Re: [CDO/OCL] Bug in error handling causes misleading LegacyModeNotEnabledException [message #916153 is a reply to message #916147] Tue, 18 September 2012 16:12 Go to previous message
Warwick Burrows is currently offline Warwick Burrows
Messages: 87
Registered: July 2009
Location: Austin, TX
Member
Opened bug 389826 for this.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=389826
Previous Topic:How to create a "details details binding"
Next Topic:[CDO] experience with huge data amount
Goto Forum:
  


Current Time: Tue Sep 23 10:37:57 GMT 2014

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

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