Skip to content

Use Thread.join instead of sleep in WaitTest - #4971

Open
therealemmanueloppong wants to merge 1 commit into
kubernetes-client:masterfrom
therealemmanueloppong:test/wait-test-join-instead-of-sleep
Open

therealemmanueloppong wants to merge 1 commit into
kubernetes-client:masterfrom
therealemmanueloppong:test/wait-test-join-instead-of-sleep

Conversation

@therealemmanueloppong

Copy link
Copy Markdown
Contributor

Notes

Thank you for maintaining this project.

WaitTest.pollShutsDownExecutorThreadAfterReturning waits for the worker thread to terminate with a hand-written loop that calls Thread.sleep(10) between isAlive() checks, up to a 2 second deadline. Thread.join(2000) waits for exactly that event with the same upper limit, so the loop and the Thread.sleep can go away.

Behaviour is unchanged: the test still waits up to 2 seconds for the worker to stop and then asserts that it is no longer alive. This is a small cleanup and not a speed-up, since the test already finished in well under 0.1 seconds. I only changed this one test file.

Related issue

Part of #1223

Testing

  • WaitTest passes (ran it 3 times).
  • mvn spotless:check passes for the util module.

pollShutsDownExecutorThreadAfterReturning waited for the worker thread
to stop with a hand-written loop that slept 10 ms between checks. Use
Thread.join with the same 2 second limit, which waits for exactly the
event the test cares about and removes the Thread.sleep.

Part of kubernetes-client#1223.
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: therealemmanueloppong
Once this PR has been reviewed and has the lgtm label, please assign brendandburns for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant