db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ilkka Priha <impr...@surfeu.fi>
Subject [PATCH] StackOverflowException in DescriptorRepository
Date Thu, 29 Jan 2004 12:18:07 GMT
Hi,

The attached class descriptor causes a stack overflow during a query if there 
are not separate class descriptors for all extent classes, too. This is because 
in such case they inherit the class descriptor of their parent, which causes an 
infinite recursion when DescriptorRepository resolves extent classes of the 
parent. However, this descriptor is very useful, e.g. when maintaining localized 
resource bundles in a database. It would be redundant to redefine the same 
descriptor for all supported locales.

The following simple patch tests cyclic references and enables this kind of 
descriptors without side effects to current behavior.

-- Ilkka


Index: DescriptorRepository.java
===================================================================
retrieving revision 1.45
diff -u -r1.45 DescriptorRepository.java
--- DescriptorRepository.java	7 Jan 2004 19:11:10 -0000	1.45
+++ DescriptorRepository.java	29 Jan 2004 12:16:41 -0000
@@ -362,6 +362,12 @@
          {
              Class extentClass = (Class) iter.next();
              ClassDescriptor extCld = getDescriptorFor(extentClass);
+            if (aCld.equals(extCld))
+            {
+                // prevent infinite recursion caused by cyclic references
+                continue;
+            }
+
              if (!extCld.isInterface())
              {
                  concreteSubclasses.add(extentClass);
@@ -391,6 +397,12 @@
          {
              Class extentClass = (Class) iter.next();
              ClassDescriptor extCld = getDescriptorFor(extentClass);
+            if (aCld.equals(extCld))
+            {
+                // prevent infinite recursion caused by cyclic references
+                continue;
+            }
+
              if (!extCld.isInterface())
              {
                  concreteSubclassClds.add(extCld);


<class-descriptor class="org.norther.tammi.Dictionary"
     table="RESOURCE_LOCALE">
     <extent-class class-ref="tammi.manual.Dictionary_en"/>
     <extent-class class-ref="tammi.manual.Dictionary_fi"/>
     <extent-class class-ref="tammi.manual.Dictionary_sv"/>
     <extent-class class-ref="tammi.manual.Dictionary_fr"/>
     <extent-class class-ref="tammi.manual.Dictionary_de"/>
     <extent-class class-ref="tammi.manual.Dictionary_ru"/>
     <field-descriptor
         name="Id"
         column="ID"
         jdbc-type="BIGINT"
         primarykey="true"
         autoincrement="true"/>
     <field-descriptor
         name="Language"
         column="LANGUAGE"
         jdbc-type="VARCHAR"/>
     <field-descriptor
         name="Country"
         column="COUNTRY"
         jdbc-type="VARCHAR"/>
     <field-descriptor
         name="Variant"
         column="VARIANT"
         jdbc-type="VARCHAR"/>
     <collection-descriptor
         name="Resources"
         element-class-ref="fi.simsoft.tammi.LocalizedValue"
         refresh="true"
         auto-retrieve="true"
         auto-update="true"
         auto-delete="true">
         <inverse-foreignkey field-ref="LocaleId"/>
     </collection-descriptor>
</class-descriptor>




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message