Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PublishCallCh.afterAckCallback race condition
Related to https://stackoverflow.com/questions/66071476/impossible-nullpointerexception-springframework-rabbitmq-failed-to-invoke When we have several pending confirms, we handle them concurrently in the `doHandleConfirm()`. The `afterAckCallback` can be set `null` in one thread and another will fail with NPE after acquiring a monitor from the `getPendingConfirmsCount()`. * Extract a local variable for the `callback` inside an `if` block * Initialize it with `this.afterAckCallback` only if `getPendingConfirmsCount() == 0` is true, and set `this.afterAckCallback` to null inside `synchronized (this)` block * Call `callback.accept(this)` when local variable is not `null` and outside of `synchronized` for better performance on end-user callback **Cherry-pick to 2.2.x**
- Loading branch information