nodece commented on code in PR #25240:
URL: https://github.com/apache/pulsar/pull/25240#discussion_r3231521977
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -2052,7 +2076,7 @@ public ManagedLedgerInterceptor
getManagedLedgerInterceptor() {
return managedLedgerInterceptor;
}
- void clearPendingAddEntries(ManagedLedgerException e) {
+ synchronized void clearPendingAddEntries(ManagedLedgerException e) {
Review Comment:
Current implementation may still hit an NPE due to the non-atomic
`isEmpty()` + `poll()` sequence.
This method can be simplified and made safer as:
```java
OpAddEntry op;
while ((op = pendingAddEntries.poll()) != null) {
op.failed(e);
}
```
This avoids the race condition between `isEmpty()` and `poll()`.
--
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]