This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch branch-2.8 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 98a5bca30af53f0b99936098ad8a199e8cc8b357 Author: Matteo Merli <mme...@apache.org> AuthorDate: Wed Sep 22 11:21:27 2021 -0700 Fixed used after recycle issue in OpAddEntry (#12103) --- .../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 665b138..9106b4f 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 @@ -277,18 +277,19 @@ public class OpAddEntry extends SafeRunnable implements AddCallback, CloseCallba /** * 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); })); }