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

Wang Yanlin edited comment on CALCITE-3388 at 10/8/19 11:40 AM:
----------------------------------------------------------------

Well, actually, this exception is not from any product environment.

I read the code of Calcite, and suspect there may be errors for this case, and 
mock an input for it.

So, if this will never happen in real project, I'm happy to close this issue. :)


was (Author: yanlin-lynn):
This exception is not from any product environment.

I read the code of Calcite, and suspect there may be errors for this case.

So, if this will never happen in real project, I'm happy to close this issue. :)

> 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)

Reply via email to