You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Danny Chen (Jira)" <ji...@apache.org> on 2019/10/08 02:02:00 UTC

[jira] [Commented] (CALCITE-3388) StackOverflowError for creating structured RelDataType from class type

    [ https://issues.apache.org/jira/browse/CALCITE-3388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16946397#comment-16946397 ] 

Danny Chen commented on CALCITE-3388:
-------------------------------------

How could a type reference itself ?
{code:java}
  private static class  RecursionStruct {
    public Integer intField;
    public RecursionStruct next;
  }
{code}
The example you gave is confusing.

> StackOverflowError for creating structured RelDataType from class type
> ----------------------------------------------------------------------
>
>                 Key: CALCITE-3388
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3388
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Wang Yanlin
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> When creating a structured RelDataType from a java type with recursion reference,
> StackOverflowError occurs, full stack trace
>   
> {noformat}
> java.lang.StackOverflowError
> 	at java.lang.Class.privateGetPublicFields(Class.java:2600)
> 	at java.lang.Class.getFields(Class.java:1557)
> 	at org.apache.calcite.rel.type.RelDataTypeFactoryImpl.fieldsOf(RelDataTypeFactoryImpl.java:440)
> 	at org.apache.calcite.rel.type.RelDataTypeFactoryImpl.access$700(RelDataTypeFactoryImpl.java:50)
> 	at org.apache.calcite.rel.type.RelDataTypeFactoryImpl$JavaType.<init>(RelDataTypeFactoryImpl.java:568)
> 	at org.apache.calcite.rel.type.RelDataTypeFactoryImpl$JavaType.<init>(RelDataTypeFactoryImpl.java:560)
> 	at org.apache.calcite.rel.type.RelDataTypeFactoryImpl$JavaType.<init>(RelDataTypeFactoryImpl.java:554)
> 	at org.apache.calcite.rel.type.RelDataTypeFactoryImpl.createJavaType(RelDataTypeFactoryImpl.java:120)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createType(JavaTypeFactoryImpl.java:143)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createStructType(JavaTypeFactoryImpl.java:82)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createType(JavaTypeFactoryImpl.java:158)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createStructType(JavaTypeFactoryImpl.java:82)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createType(JavaTypeFactoryImpl.java:158)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createStructType(JavaTypeFactoryImpl.java:82)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createType(JavaTypeFactoryImpl.java:158)
> 	at org.apache.calcite.jdbc.JavaTypeFactoryImpl.createStructType(JavaTypeFactoryImpl.java:82)
> {noformat}
> Add the test case in JavaTypeFactoryTest to reproduce the exception
> {noformat}
>  /***/
>   private static class  RecursionStruct {
>     public Integer intField;
>     public RecursionStruct next;
>   }
>   /***/
>   private static class  RecursionStruct1 {
>     public Integer intField;
>     public RecursionStruct2 struct2;
>   }
>   /***/
>   private static class  RecursionStruct2 {
>     public Integer intField;
>     public RecursionStruct1 struct1;
>   }
> @Test public void testRecursion() {
>       TYPE_FACTORY.createStructType(RecursionStruct.class);
>       TYPE_FACTORY.createStructType(RecursionStruct1.class);
>   }
> {noformat}
>  
> Better to check for recursion and throw an exception explicitly.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)