Add assertion logs for uncaught exceptions in root CompletionHandlers

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Logging
    • None
    • Fully Compatible
    • Java Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Exceptions thrown inside CompletionHandler implementations in 
      AsynchronousChannelStream can escape up to the executor’s Future returned by submit() in AsynchronousTlsChannelGroup.java#L227-L229 , where they are silently ignored.

      This means if an unexpected exception happens, for example after the user callback was already called, or due to some internal driver bugs, it neither propagates to the callback nor triggers Thread's UncaughtExceptionHandler, nor logs anything.
      Adding defensive try/catch with explicit assertion logging ensures these errors appear in logs, avoiding silent failures that make debugging and identification of such issues hard. It improves observability and simplifies troubleshooting for users and us.

      This is similar to ErrorHandlingCallback.

      Acceptance criteria:

      • Root completion handlers (WriteCompletionHandler, BasicCompletionHandler, etc.) wrap their logic in try/catch blocks.
      • Any uncaught exception is logged once at ERROR level as an assertion failure.

      This combined with JAVA-6109, JAVA-6110 ensures that the default uncaught exception handler configured by an application will have a chance to handle all Errors that originate from our code. And if there no uncaught exception handler is configured, the Error​s at least will be handled the same way the Java SE handles all uncaught exceptions by default.

            Assignee:
            Almas Abdrazak
            Reporter:
            Slav Babanin
            Nabil Hachicha, Ross Lawley, Slav Babanin, Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: