Skip to content

[ISSUE #11336] test(remoting): cover SemaphoreReleaseOnlyOnce exactly-once contract - #11345

Open
chennaji9 wants to merge 1 commit into
apache:developfrom
chennaji9:cnj/test-semaphore-release
Open

chennaji9 wants to merge 1 commit into
apache:developfrom
chennaji9:cnj/test-semaphore-release

Conversation

@chennaji9

@chennaji9 chennaji9 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #11336

Brief Description

Adds SemaphoreReleaseOnlyOnceTest with direct coverage of the class's exactly-once release contract, which currently has no dedicated test:

  • 8 threads released simultaneously (CyclicBarrier) on the same holder add exactly one permit — the timeout-vs-callback race the CAS guard exists for;
  • repeated sequential releases add no further permits;
  • a null semaphore is a silent no-op (no NPE), matching how the class is constructed for unlimited (null) semaphores.

Test-only change; no production code touched.

How Did You Test This Change?

mvn -pl remoting -Dtest=SemaphoreReleaseOnlyOnceTest -Dsurefire.failIfNoSpecifiedTests=false test (JDK 11, PR base commit): Tests run: 3, Failures: 0, Errors: 0.

…xactly-once contract

Add SemaphoreReleaseOnlyOnceTest: an 8-thread barrier race on the same
holder must add exactly one permit, sequential re-releases add none, and
a null semaphore stays a silent no-op.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.66%. Comparing base (9ea2ccd) to head (e46651e).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11345      +/-   ##
=============================================
- Coverage      49.73%   49.66%   -0.08%     
+ Complexity     14348    14329      -19     
=============================================
  Files           1390     1390              
  Lines         103246   103246              
  Branches       13502    13502              
=============================================
- Hits           51354    51277      -77     
- Misses         45696    45763      +67     
- Partials        6196     6206      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by github-manager-bot

Summary

Adds SemaphoreReleaseOnlyOnceTest pinning the exactly-once release contract of the remoting semaphore wrapper.

Findings

  • [Info] SemaphoreReleaseOnlyOnceTest.java — Three tests: sequential release (only one permit added), concurrent release (8 threads, still exactly one permit), and null semaphore safety. The CyclicBarrier coordination for the concurrent test is correct.
  • [Info] The null-semicolon test ensures no NPE, which is a valid edge case.

Suggestions

  • None. Clean and well-structured.

Automated review by github-manager-bot

@chennaji9
chennaji9 force-pushed the cnj/test-semaphore-release branch from e46651e to b52c299 Compare October 18, 2026 08:11
@chennaji9

Copy link
Copy Markdown
Contributor Author

Hi @RongtongJin, sorry for the ping — this PR has been open for a while without a review yet. The change is small and focused (cover SemaphoreReleaseOnlyOnce exactly-once contract), and all tests and CI pass on my side. Would you mind taking a look when you get a chance? If it looks good, merging it would be much appreciated — happy to adjust anything if needed. Thanks a lot!

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.

[Enhancement] SemaphoreReleaseOnlyOnce lacks direct tests for its exactly-once release contract

3 participants