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

Documentation of DuplicateKeyException should be clarified

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.0
    • Affects Version/s: 4.1.1
    • Component/s: Documentation
    • None

      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.

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

              Created:
              Updated:
              Resolved: