You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/10/05 03:09:25 UTC

[GitHub] [calcite] yanlin-Lynn commented on a change in pull request #1486: [CALCITE-3388] StackOverflowError for creating structured RelDataType from class type

yanlin-Lynn commented on a change in pull request #1486: [CALCITE-3388] StackOverflowError for creating structured RelDataType from class type
URL: https://github.com/apache/calcite/pull/1486#discussion_r331730048
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
 ##########
 @@ -69,17 +69,33 @@ public JavaTypeFactoryImpl(RelDataTypeSystem typeSystem) {
     super(typeSystem);
   }
 
+  /**
+   * Create a structured {@link RelDataType} from java type,
+   * throw exception if recursion founded.
+   */
   public RelDataType createStructType(Class type) {
+    Map<Type, Type> edges = new HashMap<>();
+    return createStructType(type, edges);
+  }
+
+  private RelDataType createStructType(Class type, Map<Type, Type> edges) {
+    Type checkType = edges.get(type);
+    while (checkType != null) {
+      if (checkType.equals(type)) {
+        throw new RuntimeException("Recursion for creating struct type unsupported");
+      }
+      checkType = edges.get(checkType);
+    }
     final List<RelDataTypeField> list = new ArrayList<>();
     for (Field field : type.getFields()) {
       if (!Modifier.isStatic(field.getModifiers())) {
-        // FIXME: watch out for recursion
 
 Review comment:
   :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services