KAFKA-18027: MINOR: Correct DelayedOperationPurgatory code around adding of an already completed operation (#17842)

Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com>, Jun Rao <junrao@gmail.com>
This commit is contained in:
Abhinav Dixit 2024-11-20 22:56:44 +05:30 committed by GitHub
parent c6294aacef
commit aa7a3dbd30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -147,7 +147,10 @@ public class DelayedOperationPurgatory<T extends DelayedOperation> {
// any exclusive lock. Since DelayedOperationPurgatory.checkAndComplete() completes delayed operations asynchronously,
// holding an exclusive lock to make the call is often unnecessary.
if (operation.safeTryCompleteOrElse(() -> {
watchKeys.forEach(key -> watchForOperation(key, operation));
watchKeys.forEach(key -> {
if (!operation.isCompleted())
watchForOperation(key, operation);
});
if (!watchKeys.isEmpty())
estimatedTotalOperations.incrementAndGet();
})) {