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

PojoCodec requires codec for BsonIgnored synthesized properties

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.10.0
    • Affects Version/s: None
    • Component/s: POJO
    • None

      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.

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

              Created:
              Updated:
              Resolved: