This is an automated email from the ASF dual-hosted git repository.
lushiji pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 2734e8bcec LedgerOpenOp: Do not call blocking close() in the callback
(#3513)
2734e8bcec is described below
commit 2734e8bcec6371cb139913624fd30953fc6c1def
Author: Andrey Yegorov <[email protected]>
AuthorDate: Fri Oct 7 19:20:27 2022 -0700
LedgerOpenOp: Do not call blocking close() in the callback (#3513)
* Do not call blocking close() in the callback
* CR feedback, remove lombok from LedgerOpenOp
---
.../org/apache/bookkeeper/client/LedgerOpenOp.java | 31 +++++++++++-----------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerOpenOp.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerOpenOp.java
index 242e0c4a97..f4a421ea32 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerOpenOp.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerOpenOp.java
@@ -129,17 +129,11 @@ class LedgerOpenOp {
initiate();
}
- private void closeLedgerHandle() {
- try {
- if (lh != null) {
- lh.close();
- }
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- LOG.info("InterruptedException while closing ledger {}", ledgerId,
e);
- } catch (BKException e) {
- LOG.warn("BKException while closing ledger {} ", ledgerId, e);
+ private CompletableFuture<Void> closeLedgerHandleAsync() {
+ if (lh != null) {
+ return lh.closeAsync();
}
+ return CompletableFuture.completedFuture(null);
}
private void openWithMetadata(Versioned<LedgerMetadata> versionedMetadata)
{
@@ -209,10 +203,13 @@ class LedgerOpenOp {
if (rc == BKException.Code.OK) {
openComplete(BKException.Code.OK, lh);
} else if (rc ==
BKException.Code.UnauthorizedAccessException) {
- closeLedgerHandle();
-
openComplete(BKException.Code.UnauthorizedAccessException, null);
+ closeLedgerHandleAsync().whenComplete((r, ex) -> {
+ if (ex != null) {
+ LOG.error("Ledger {} close failed", ledgerId,
ex);
+ }
+
openComplete(BKException.Code.UnauthorizedAccessException, null);
+ });
} else {
- closeLedgerHandle();
openComplete(bk.getReturnRc(BKException.Code.LedgerRecoveryException), null);
}
}
@@ -227,8 +224,12 @@ class LedgerOpenOp {
public void readLastConfirmedComplete(int rc,
long lastConfirmed, Object ctx) {
if (rc != BKException.Code.OK) {
- closeLedgerHandle();
-
openComplete(bk.getReturnRc(BKException.Code.ReadException), null);
+ closeLedgerHandleAsync().whenComplete((r, ex) -> {
+ if (ex != null) {
+ LOG.error("Ledger {} close failed", ledgerId,
ex);
+ }
+
openComplete(bk.getReturnRc(BKException.Code.ReadException), null);
+ });
} else {
lh.lastAddConfirmed = lh.lastAddPushed = lastConfirmed;
openComplete(BKException.Code.OK, lh);