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

PojoCodec requires codec for BsonIgnored synthesized properties

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 3.10.0
    • None
    • POJO
    • None

    Description

      If a property is synthetic (e.g. has no backing field) and is annotated with @BsonIgnore then it shouldn't require a codec for the property.

      import org.bson.codecs.pojo.annotations.BsonIgnore;
       
      public class MyPojo {
          private final String stringField;
       
          MyPojo(final String stringField) {
              this.stringField = stringField;
          }
       
          public String getStringField() {
              return stringField;
          }
       
          @BsonIgnore
          public Object getSyntheticProperty() {
              return null;
          }
      }
      

      With the above example there is no need for a Codec<Object>.
      The ConventionAnnotationImpl needs updating, to handle for synthetic getters / setters.

      Attachments

        Activity

          People

            ross@mongodb.com Ross Lawley
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: