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

Documentation of DuplicateKeyException should be clarified

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.3.0
    • 4.1.1
    • Documentation
    • None

    Description

      The documentation of `DuplicateKeyException` states:

      > Subclass of WriteConcernException representing a duplicate key exception

      And `WriteConcernException` in turn:

      > An exception representing an error reported due to a write failure.

      This is confusing. From the documentation one has to assume that `DuplicateKeyException` is thrown in case a duplicate key is encountered during a write operation.
      What's actually thrown is a `MongoCommandException` with `ErrorCategory.fromErrorCode(e.code) == ErrorCategory.DUPLICATE_KEY`.

      The documentation of `DuplicateKeyException` should be amended to clarify that it's not actually used (in certain situations) in this case counter to what the developer may expect or assume.

      Attachments

        Activity

          People

            jeff.yemin@mongodb.com Jeffrey Yemin
            marc@knaup.io Marc Knaup
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: