Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4745

Handle recursive types in parameterized records

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.8.0
    • Affects Version/s: None
    • Component/s: POJO
    • None
    • Fully Compatible
    • Needed

      The implementation of JAVA-4740 (Support deserialization of records with generic parameters) doesn't handle recursive types, and will result in a runtime recursion that is only halted by a StackOverflowException. We need a different design in order to handle this case properly. An example to make it clearer:

      public record RecordTree<T>(T content,
                                 @Nullable RecordTree<T> left,
                                 @Nullable RecordTree<T> right) {
      }
      

      The RecordCodec should be able to handle a record like that, and in general, any sort of cyclical reference. Note that this isn't about actual cycles in the object graph. It's about cycles in the static type definitions.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: