[JAVA-2979] PojoCodec requires codec for BsonIgnored synthesized properties Created: 18/Sep/18  Updated: 28/Oct/23  Resolved: 13/Dec/18

Status: Closed
Project: Java Driver
Component/s: POJO
Affects Version/s: None
Fix Version/s: 3.10.0

Type: Bug Priority: Major - P3
Reporter: Ross Lawley Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.



 Comments   
Comment by Githook User [ 14/Jan/19 ]

Author:

{'username': 'rozza', 'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley'}

Message: Ensure synthetic ignored properties don't require a Codec

JAVA-2979
Branch: 3.10.x
https://github.com/mongodb/mongo-java-driver/commit/c05ea821c2935bc68b6b727b6634d83516873404

Comment by Ian Whalen (Inactive) [ 13/Dec/18 ]

ross.lawley should this have a fixversion?

Comment by Githook User [ 13/Dec/18 ]

Author:

{'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley', 'username': 'rozza'}

Message: Ensure synthetic ignored properties don't require a Codec

JAVA-2979
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e9fd82a3825d6e985fc3d49bff05028b139341d3

Generated at Thu Feb 08 08:58:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.