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

Allow both BsonDiscriminator key and value to be used in the discriminator lookup

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Codecs, POJO
    • None
    • Java Drivers
    • Not Needed

      Currently, only the value is used and depending on use this may increase the likelyhood of discriminator clashes.

      Allowing both the key and value to be used, allows for conflict free discriminators and can be safely used as the discriminator look up key rather than just the value. Doing so won't impact current users but will allow more flexibility for future users.


      Was:

      Patch ability to overwrite bson discriminator classes across a codec.

      Minimum repro is here: https://github.com/10gen/mms/pull/105109

      Context is here: https://mongodb.slack.com/archives/C0V5KNS3X/p1722569794099499

      TLDR is that currently, discriminators are unique by value, which exacerbates their ability to create conflicts. It would be better if this were separated somehow by codec, or even by discriminator <key, value> pair, and if there was some type of warning or error on two entries being entered.

       

      I don't know how complicated the first option is, but adding an error or separating by <key, value> both seem very straightforward.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            james.strynkowski@mongodb.com James Strynkowski
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: