chennaji9 opened a new issue, #11336:
URL: https://github.com/apache/rocketmq/issues/11336
### Description
`SemaphoreReleaseOnlyOnce`
(`remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java`)
is the guard that keeps the remoting layer's semaphore-based flow control
(async/oneshot request permits) from leaking permits on double release. Its
entire contract is the single line:
```java
if (this.released.compareAndSet(false, true)) {
this.semaphore.release();
}
```
`NettyRemotingAbstractTest` exercises permit counts through higher-level
call paths, but there is no direct unit test for this class — in particular
none that races multiple threads calling `release()` on the *same* holder,
which is the exact scenario the CAS exists for (response timeout racing the
response callback), and none for the documented null-semaphore no-op.
A regression that breaks the exactly-once guarantee (e.g. replacing the CAS
with a plain check-then-act, or dropping the null guard) would currently pass
the existing suites.
### Expected behavior
Direct regression coverage: N threads released simultaneously must add
exactly one permit; repeated sequential releases must not add more; a null
semaphore must be a silent no-op.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]