Nested wildcard generic type stops automatic POJO codec creation

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 4.1.1
    • Component/s: POJO
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Using nested wildcard generic types causes exception and no automatic POJO codec will be build. I have a helper method of this style in a model class:

      @BsonIgnore
      public List<? extends A<? extends B>> getSomeAObjects() {
        cObject.getAObjects();
      }
      

      Processing the return type of this method via PojoBuilderHelper.configureClassModelBuilder() throws an exception in TypeDate.getNestedTypeData() in the type instanceof WildcardType branch. This tries to cast the result of ((WildcardType) type).getUpperBounds()[0] to Class which will not work in this case as the upper bound type is a ParameterizedType. An exception is thrown which stops the automatic Codec creation.

      This issue was introduced in JAVA-3390 and prevents us from updating to a 4.x driver version. It is also unfortunate that even the @BsonIgnore does not prevent this from happening.

            Assignee:
            Unassigned
            Reporter:
            Sebastian Bober
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: