This is an automated email from the ASF dual-hosted git repository.

technoboy pushed a commit to branch branch-2.11
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.11 by this push:
     new 4c568a948e8 [fix][schema] Only handle exception when there has (#20730)
4c568a948e8 is described below

commit 4c568a948e820c6943023dddc255750b6ec9c51b
Author: Yong Zhang <[email protected]>
AuthorDate: Thu Jul 6 16:08:45 2023 +0800

    [fix][schema] Only handle exception when there has (#20730)
---
 .../service/schema/BookkeeperSchemaStorage.java    | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
index d538a89ff07..bdc986bc513 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
@@ -470,18 +470,20 @@ public class BookkeeperSchemaStorage implements 
SchemaStorage {
                         concat(locator.getIndexList(), newArrayList(info))
                 ).build(), locatorEntry.version
         ).thenApply(ignore -> nextVersion).whenComplete((__, ex) -> {
-            Throwable cause = FutureUtil.unwrapCompletionException(ex);
-            log.warn("[{}] Failed to update schema locator with position {}", 
schemaId, position, cause);
-            if (cause instanceof AlreadyExistsException || cause instanceof 
BadVersionException) {
-                bookKeeper.asyncDeleteLedger(position.getLedgerId(), new 
AsyncCallback.DeleteCallback() {
-                    @Override
-                    public void deleteComplete(int rc, Object ctx) {
-                        if (rc != BKException.Code.OK) {
-                            log.warn("[{}] Failed to delete ledger {} after 
updating schema locator failed, rc: {}",
+            if (ex != null) {
+                Throwable cause = FutureUtil.unwrapCompletionException(ex);
+                log.warn("[{}] Failed to update schema locator with position 
{}", schemaId, position, cause);
+                if (cause instanceof AlreadyExistsException || cause 
instanceof BadVersionException) {
+                    bookKeeper.asyncDeleteLedger(position.getLedgerId(), new 
AsyncCallback.DeleteCallback() {
+                        @Override
+                        public void deleteComplete(int rc, Object ctx) {
+                            if (rc != BKException.Code.OK) {
+                                log.warn("[{}] Failed to delete ledger {} 
after updating schema locator failed, rc: {}",
                                     schemaId, position.getLedgerId(), rc);
+                            }
                         }
-                    }
-                }, null);
+                    }, null);
+                }
             }
         });
     }

Reply via email to