You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/12/11 14:27:23 UTC
[pulsar] 07/10: Fixed used after recycle issue in OpAddEntry (#12103)
This is an automated email from the ASF dual-hosted git repository.
penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit bae19a7feeedde76ec2a3eb43ed35a8500718184
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Wed Sep 22 11:21:27 2021 -0700
Fixed used after recycle issue in OpAddEntry (#12103)
(cherry picked from commit 3c4597db80bc229bb32cf7600bf879c39808c1b4)
---
.../java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
index 2c5c3b2..e42ce25 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
@@ -253,18 +253,19 @@ class OpAddEntry extends SafeRunnable implements AddCallback, CloseCallback {
/**
* It handles add failure on the given ledger. it can be triggered when add-entry fails or times out.
*
- * @param ledger
+ * @param lh
*/
- void handleAddFailure(final LedgerHandle ledger) {
+ void handleAddFailure(final LedgerHandle lh) {
// If we get a write error, we will try to create a new ledger and re-submit the pending writes. If the
- // ledger creation fails (persistent bk failure, another instanche owning the ML, ...), then the writes will
+ // ledger creation fails (persistent bk failure, another instance owning the ML, ...), then the writes will
// be marked as failed.
- ml.mbean.recordAddEntryError();
+ ManagedLedgerImpl finalMl = this.ml;
+ finalMl.mbean.recordAddEntryError();
- ml.getExecutor().executeOrdered(ml.getName(), SafeRun.safeRun(() -> {
+ finalMl.getExecutor().executeOrdered(finalMl.getName(), SafeRun.safeRun(() -> {
// Force the creation of a new ledger. Doing it in a background thread to avoid acquiring ML lock
// from a BK callback.
- ml.ledgerClosed(ledger);
+ finalMl.ledgerClosed(lh);
}));
}