Add stack-safe loop execution to async framework

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • 5.7.0
    • Affects Version/s: None
    • Component/s: Async
    • None
    • None
    • Java Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Async loops (thenRunDoWhileLoop) can crash with StackOverflowError when loop iterations complete synchronously on the same thread. In same-thread completion scenarios, the callback for the next iteration is invoked on the same stack, causing recursive stack growth which can lead to the stack overflow.

      Example call stack growth (simplified)

      LoopingCallback.onResult() [iteration 1]
        → body.run(this)
          → body completes synchronously
            → LoopingCallback.onResult() [iteration 2]
              → body.run(this)
                → body completes synchronously
                  → LoopingCallback.onResult() [iteration 3]
                    → ...
                      → StackOverflowError at N iterations

      Acceptance Criteria

      • Stack depth remains constant with iteration count (no recursion).
      • Behavior remains unchanged for iterations completing asynchronously on other threads.
      • Implement thenRunWhileLoop with equivalent stack-safety guarantees.

            Assignee:
            Slav Babanin
            Reporter:
            Slav Babanin
            Almas Abdrazak, Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: