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

Nested wildcard generic type stops automatic POJO codec creation

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • 4.1.1
    • POJO
    • None

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebastianbober@fico.com Sebastian Bober
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: