Skip to content

Avoid changing global uncaught exception handler - #12076

Open
Suthankan1 wants to merge 1 commit into
testcontainers:mainfrom
Suthankan1:fix/docker-strategy-uncaught-handler
Open

Suthankan1 wants to merge 1 commit into
testcontainers:mainfrom
Suthankan1:fix/docker-strategy-uncaught-handler

Conversation

@Suthankan1

@Suthankan1 Suthankan1 commented Sep 14, 2026

Copy link
Copy Markdown

What changed

Disable Awaitility's uncaught-exception interception for the Docker client strategy socket check.

Awaitility otherwise temporarily replaces the JVM-wide default uncaught exception handler while DockerClientProviderStrategy checks whether the Docker endpoint is reachable. This can intercept exceptions from unrelated threads.

Using dontCatchUncaughtExceptions() keeps the existing timeout and polling behavior while avoiding the global handler mutation.

A regression test verifies that the JVM default uncaught exception handler remains unchanged while the Docker strategy check runs.

Testing

  • DockerClientProviderStrategyTest — RED before the fix, GREEN after
  • regression test passed 20 consecutive runs
  • related dockerclient tests passed
  • Spotless and Checkstyle passed

The full :testcontainers:test run also encountered unrelated Docker image download failures caused by local DNS/network resolution of production.cloudfront.docker.com.

Fixes #11483

Summary by CodeRabbit

  • Bug Fixes
    • Docker connection checks now allow unexpected background exceptions to propagate instead of being silently swallowed.
    • Improved reliability when diagnosing Docker connectivity failures.
    • Preserved the JVM’s default uncaught-exception handler during Docker environment checks.
  • Tests
    • Added coverage verifying exception handling behavior during Docker client strategy checks.

@Suthankan1
Suthankan1 requested a review from a team as a code owner September 14, 2026 03:29
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

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: df370c4f-11d2-494a-9a3a-7a4692c4daed

📥 Commits

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

📒 Files selected for processing (2)
  • core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java
  • core/src/test/java/org/testcontainers/dockerclient/DockerClientProviderStrategyTest.java

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


📝 Walkthrough

Walkthrough

DockerClientProviderStrategy.test() now prevents Awaitility from intercepting uncaught exceptions during polling. A regression test verifies that the JVM default uncaught exception handler remains unchanged during strategy execution.

Changes

Uncaught Exception Handler Preservation

Layer / File(s) Summary
Awaitility polling behavior
core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java
The test() Awaitility chain calls .dontCatchUncaughtExceptions().
Handler regression test
core/src/test/java/org/testcontainers/dockerclient/DockerClientProviderStrategyTest.java
The test observes the default uncaught exception handler during strategy execution, verifies the listener ran, and restores the original handler.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: eddumelendez

Merge Risk: ⚪ Minimal · up to 27dd8

The Docker strategy no longer changes the JVM-wide uncaught-exception handler during endpoint polling, with regression coverage for that behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 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 describes the primary change: preventing changes to the global uncaught exception handler.
Description check ✅ Passed The description explains the behavior change, the affected code path, the regression test, test results, and linked issue. It meets the repository template requirements.
Linked Issues check ✅ Passed The change addresses #11483. DockerClientProviderStrategy.test() now calls dontCatchUncaughtExceptions() before the existing timeout and polling configuration. This prevents Awaitility from instal…
Out of Scope Changes check ✅ Passed The pull request changes only the Docker strategy Awaitility configuration and adds a focused regression test for #11483. The test isolation annotations and cleanup support verification of JVM-global …
  • Fix all pre-merge checks with AI

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.

[Bug]: Running testcontainers temporarily changes global uncaught exception handler

1 participant