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

@BsonIgnore doesn't prevent PojoBuilderHelper.configureClassModelBuilder from calling getTypeData on ignored fields

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.5.0
    • Fix Version/s: 3.6.0
    • Component/s: POJO
    • Labels:
      None

      Description

      In a POJO if you have a field or method that is marked with @BsonIgnore , and if this is a type disallowed by the TypeData$Builder the class model creation will fail - despite this field / method not being required.

      Example exception

      java.lang.IllegalStateException: Invalid Map type. Maps MUST have string keys, found class com.TestEnum instead.
      	at org.bson.codecs.pojo.TypeData$Builder.validate(TypeData.java:117)
      	at org.bson.codecs.pojo.TypeData$Builder.build(TypeData.java:104)
      	at org.bson.codecs.pojo.PojoBuilderHelper.getTypeData(PojoBuilderHelper.java:158)
      	at org.bson.codecs.pojo.PojoBuilderHelper.configureClassModelBuilder(PojoBuilderHelper.java:87)
      	at org.bson.codecs.pojo.ClassModelBuilder.<init>(ClassModelBuilder.java:59)
      	at org.bson.codecs.pojo.ClassModel.builder(ClassModel.java:63)
      	at org.bson.codecs.pojo.PojoCodecProvider.createClassModel(PojoCodecProvider.java:194)
      	at org.bson.codecs.pojo.PojoCodecProvider.access$100(PojoCodecProvider.java:38)
      	at org.bson.codecs.pojo.PojoCodecProvider$Builder.build(PojoCodecProvider.java:115)
      

      Here the pojo contains a Map keyed on an enum. This map is marked with @BsonIgnore, hence I would not expect the failure above.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ross.lawley Ross Lawley
              Reporter:
              edwaki Kieron Edwards
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: