Skip to content

Fix timeout overflow when waiting for end of output - #12093

Open
LindseyZ1205 wants to merge 1 commit into
testcontainers:mainfrom
LindseyZ1205:fix/waiting-consumer-timeout-overflow
Open

LindseyZ1205 wants to merge 1 commit into
testcontainers:mainfrom
LindseyZ1205:fix/waiting-consumer-timeout-overflow

Conversation

@LindseyZ1205

@LindseyZ1205 LindseyZ1205 commented Sep 29, 2026 •

Copy link
Copy Markdown

WaitingConsumer.waitUntilEnd(long, TimeUnit) adds the converted timeout to System.nanoTime(). For very large positive timeouts, such as Long.MAX_VALUE nanoseconds or a conversion saturated at Long.MAX_VALUE, the absolute deadline can overflow. On a JVM with a positive nanoTime() value, this immediately throws TimeoutException, even when OutputFrame.END is already queued.

Compare elapsed time against the timeout instead, matching the existing waitUntil implementation. The no-argument overload now also uses a relative timeout. No public API changes.

Regression coverage includes maximum and saturated timeouts, the no-argument overload, an ordinary finite timeout, and expiration without an END frame.

Validation: the original source fails both large-timeout regression cases (2 failures out of 5 tests). With this change, all 5 WaitingConsumer tests and 12 FrameConsumerResultCallback tests pass. Module checkstyleMain, checkstyleTest, and spotlessApply pass. Full ./gradlew check and Docker integration tests were not run because the local Docker daemon is unavailable.

AI assistance: Codex assisted with investigation, implementation, and regression tests.

Summary by CodeRabbit

  • Bug Fixes
    • Waiting for container output to finish now handles very large, unlimited, and finite timeout values correctly, including when the end marker has already arrived.
    • When the end marker does not arrive within the requested interval, the wait still ends with a timeout error.

@LindseyZ1205
LindseyZ1205 requested a review from a team as a code owner September 29, 2026 12:47
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: cd8dc5fc-d30e-4544-a915-db10cd982b6c

📥 Commits

Reviewing files that changed from the base of the PR and between 8e54951 and b86886f.

📒 Files selected for processing (2)
  • core/src/main/java/org/testcontainers/containers/output/WaitingConsumer.java
  • core/src/test/java/org/testcontainers/containers/output/WaitingConsumerTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

WaitingConsumer now compares elapsed time with a timeout duration. New tests cover received end frames and timeout expiry.

Changes

WaitingConsumer timeout

Layer / File(s) Summary
Elapsed-time timeout handling
core/src/main/java/org/testcontainers/containers/output/WaitingConsumer.java, core/src/test/java/org/testcontainers/containers/output/WaitingConsumerTest.java
waitUntilEnd passes a nanosecond timeout duration to the private wait method, which checks elapsed time against that duration. Tests cover maximum and saturated timeouts, no timeout, a finite timeout, and expiry without an end frame.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: eddumelendez

Merge Risk: ⚪ Minimal · up to b8688

The timeout fix is ready to merge after normal checks. No actionable regression was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing timeout overflow when waiting for the end of output.
Description check ✅ Passed The description explains the broken behavior, the cause, the fix, regression coverage, validation results, and tests that were not run. It satisfies the repository template requirements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant