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

Add Query Deserialization Validation for unrecognized fields



    • Type: New Feature
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Codecs
    • Labels:


      When the Mongo Java Driver deserializes BSON objects to POJOs it ignores fields that it does not recognize.

      We are interested in a new feature that would enable throwing exceptions when unknown fields are found while deserializing using the PojoCodec. There is behavior analogous to this in the .NET driver.

      It seems like there were a couple options discussed in the original POJO codec project when considering what to do when we find fields in documents that are not found in the Java POJO objects. Taken from that ticket, those were:

      1. (currently implemented) skipping that document field
      2. Throwing an exception
      3. Dumping extra fields to an optional BsonDocument on the object to hold the extra fields

      Would you all consider an implementation that would (optionally) take approach (2) or (3)? We would be interested in submitting a PR if you agree that the functionality would be useful and worth adding.


          Issue Links



              • Votes:
                0 Vote for this issue
                6 Start watching this issue


                • Created: