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.
- is derived by
-
JAVA-6071 Test failures due to connection leaks and unexpected exceptions in bulk write tests
-
- Investigating
-