StackOverflowException invoking isSet on a static DataObject with a 
dynamically-added property
----------------------------------------------------------------------------------------------

                 Key: TUSCANY-1484
                 URL: https://issues.apache.org/jira/browse/TUSCANY-1484
             Project: Tuscany
          Issue Type: Bug
          Components: Java SDO Implementation
    Affects Versions: Java-SDO-Next
            Reporter: Ron Gavlin


I have a Type and a corresponding statically-generated class. At runtime, I 
dynamically add an add'l Property to this Type using SDOUtil.createProperty(). 
Then, when I invoke dataObjectInstance.isSet(dynamicallyAddedProperty), the  
StackOverflowException listed below is generated:

> java.lang.StackOverflowError
> at mypackage.impl.MyFactoryImpl.getMyType(MyFactoryImpl.java:1135)
>
>
> at mypackage.impl.MyTypeImpl.getStaticType(MyTypeImpl.java:821)
> at org.apache.tuscany.sdo.impl.DataObjectBase.
> eStaticClass(DataObjectBase.java:378)
> at org.apache.tuscany.sdo.impl.ExtensibleDataObjectImpl.
> eClass(ExtensibleDataObjectImpl.java:118)
> at org.apache.tuscany.sdo.impl.ExtensibleDataObjectImpl.
> eDerivedStructuralFeatureID(ExtensibleDataObjectImlp.java:87)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.
> eIsSet(BasicEObjectimpl.java:815)
>
> at
org.apache.tuscany.sdo.impl.DataObjectImpl.isSet(DataObjectImpl.java:152)
>
> at
org.apache.tuscany.sdo.impl.DataObjectImpl.isSet(DatObjectImpl.java:112)
>
> at mypackage.sdo.impl.MyTypeImpl.setSet(MyTypeImpl.java:2005)
>
>
> at
org.apache.tuscany.sdo.impl.DataObjectBase.eIsSet(DataObjectBase.java:437)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.
> eIsSet(BasicEObjectimpl.java:818)
> at
org.apache.tuscany.sdo.impl.DataObjectImpl.isSet(DataObjectImpl.java:152)
> at
org.apache.tuscany.sdo.impl.DataObjectImpl.isSet(DatObjectImpl.java:112)
> ...
> at mypackage.sdo.impl.MyTypeImpl.setSet(MyTypeImpl.java:2005)
>
> at
org.apache.tuscany.sdo.impl.DataObjectBase.eIsSet(DataObjectBase.java:437)
>
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.
> eIsSet(BasicEObjectimpl.java:818)
>
> at
org.apache.tuscany.sdo.impl.DataObjectImpl.isSet(DataObjectImpl.java:152)
>
> at
org.apache.tuscany.sdo.impl.DataObjectImpl.isSet(DatObjectImpl.java:112)
>
> ...
>

Frank's characterization of the problem is included below.

----- Original Message ----
From: Frank Budinsky <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Thursday, July 26, 2007 3:03:15 PM
Subject: Re: How to add Property to an XSDHelper-defined Type

Since the properties start at 0, the extra property number should be equal
to INTERNAL_PROPERTY_COUNT. That looks right.

The StackOverflowException problem looks to me to be caused by the fact
that the generated methods like isSet(int) are expected to find the
property and only call super in the dynamic case. In your case, the
property isn't statically handled, so it eventually calls
DataObjectBase.eIsSet():

  public boolean eIsSet(int featureID)
  {
    if (isDynamic())
    {
      return super.eIsSet(internalConvertIndex(featureID));
    } else
    {
      return isSet(internalConvertIndex(featureID));
    }
  }

which will recursively call isSet() again because isDynamic() returns
false. Somehow the code needs to be changed so that the dynamic property
also causes it to go down the isDynamic() path.

Actually, this eIsSet() method looks fishy to me regardless. First, the
call to internalConvertIndex(featureID) for the call to super.eIsSet()
looks wrong to me. I think it should be just featureID. The super call is
expecting the internal (EMF) number, not the converted SDO number. Second,
even in the dynamic sublass case (which this is supposed to be handling, I
think that a client call to eIsSet() won't work, because it won't ever go
down the isSet() patch which handles the static properties (in the base
class(es)).

I think the isDynamic() part of this method should be removed and instead
there should be an implementation of isSet(int) (in ExtensibleDataObject
probably?) that handles the case of a property that is either in a dynamic
sublass or was dynamically added to a static type.

Frank.


Ron Gavlin <[EMAIL PROTECTED]> wrote on 07/26/2007 01:09:27 PM:

> Frank,
>
> This scenario appears to trigger a property-indexing problem. The
> newly added property's EMF featureID of 18 equals the value of
> MyTypeImpl.SDO_PROPERTY_COUNT and MyTypeImpl.
> INTERNAL_PROPERTY_COUNT. This appears to cause an infinite loop. Any
> ideas for working around this problem?
>
> - Ron
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to