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

BSON Ignore in POJO Codec not working as expected on methods

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.6.1
    • Component/s: Codecs
    • None

      Summary

      When using codecs with a POJO, any extra methods beginning with the keyword get or set will trigger exceptions, even if the method is marked with the @BsonIgnore annotation.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      4.6.1

      How to Reproduce

      Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.

      public class User {
          @BsonId
          private ObjectId mongoID;

          @BsonIgnore
          public User setMongoID (String mongoID) {
              this.mongoID = new ObjectId(mongoID);
              return this;
          }
          public User setMongoID (ObjectId mongoID) {
              this.mongoID = mongoID;
              return this;
          }
          public ObjectId getMongoID() {
              return mongoID;
          }
      }

       

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            dennis@nornir.io Dennis Lee
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: