Investigate inconsistent error label copying in MongoException constructors

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Java Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Background

      During the review of PR #1899, it was identified that MongoException constructors behave inconsistently with respect to
      copying error labels from a cause exception:

      • MongoException(final int code, final String msg, final Throwable t)copies error labels from the cause.
      • MongoException(@Nullable final String msg, @Nullable final Throwable t) — does not copy error labels from the cause.

      Problem

      This inconsistency affects the withTransaction timeout error behavior introduced in DRIVERS-3391. When withTransaction creates a timeout error wrapping the last retried error, error labels (such as
      TransientTransactionError and UnknownTransactionCommitResult) from the wrapped exception may not be propagated to the timeout error, depending on which constructor is used.

      Since these error labels are publicly documented, they must be reliably accessible on the top-level error
      returned to callers.

      Action Items

      1. Investigate whether the omission of label copying in MongoException(@Nullable final String msg, @Nullable final Throwable t) was intentional or a bug.
      2. If it was intentional, document the rationale and determine if withTransaction needs a different approach to propagate labels.
      3. If it was a bug, fix the constructor to copy labels from the cause, consistent with the other constructor.

      References

            Assignee:
            Unassigned
            Reporter:
            Nabil Hachicha
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: