You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/29 06:18:17 UTC

[GitHub] [pulsar] eolivelli commented on a diff in pull request #16857: [fix][broker] PulsarLedgerManager to pass correct error code to BK client

eolivelli commented on code in PR #16857:
URL: https://github.com/apache/pulsar/pull/16857#discussion_r932903084


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/PulsarLedgerManager.java:
##########
@@ -89,6 +89,20 @@ public LedgerMetadata deserialize(String path, byte[] content, Stat stat) throws
         store.registerListener(this::handleDataNotification);
     }
 
+    private static Throwable mapToBkException(Throwable ex) {
+        if (ex instanceof MetadataStoreException.NotFoundException) {
+            return BKException.create(BKException.Code.NoSuchLedgerExistsOnMetadataServerException);

Review Comment:
   What about calling initCause and add the original error to the chain?



##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/PulsarLedgerManager.java:
##########
@@ -106,14 +120,21 @@ public CompletableFuture<Versioned<LedgerMetadata>> createLedgerMetadata(long le
             return FutureUtil.failedFuture(new BKException.BKMetadataSerializationException(ioe));
         }
 
+        CompletableFuture<Versioned<LedgerMetadata>> promise = new CompletableFuture<>();
+
         CompletableFuture<Versioned<LedgerMetadata>> future = store.put(getLedgerPath(ledgerId), data, Optional.of(-1L))
-                .thenApply(stat -> new Versioned(metadata, new LongVersion(stat.getVersion())));
+                .thenApply(stat -> {

Review Comment:
   Nit:
   We can replace this with thenAccept
   or the both of the two calls (apply and exceptionally) with whenComplete



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org