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

yong pushed a commit to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git

commit e5d86d36e3a45a70f41df9707ac82139643607c5
Author: Zhangao <[email protected]>
AuthorDate: Tue Aug 29 14:59:27 2023 +0800

    Optimize getEntryLogMetadata (#3948)
    
    ###Motivation
    
    In the `getEntryLogMetadata` method, the `FileNotFoundException` exception 
is caught before the more general Exception. This modification ensures that if 
the log file is not found, there is no need to proceed with the 
`extractEntryLogMetadataByScanning(entryLogId, throttler)` method call.
    
    This enhancement improves the code's error handling by distinguishing 
between different exceptions that may occur during the retrieval of entry log 
metadata. It ensures that unnecessary operations, scanning the log, are skipped 
when the log file is not found.
    
    (cherry picked from commit 69f27b71c6a6ef051b5aba718cca0c209e9e17db)
---
 .../src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java        | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
index d69e434ef5..28e3297ef2 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
@@ -1064,6 +1064,9 @@ public class EntryLogger {
         // entry log
         try {
             return extractEntryLogMetadataFromIndex(entryLogId);
+        } catch (FileNotFoundException fne) {
+            LOG.warn("Cannot find entry log file {}.log : {}", 
Long.toHexString(entryLogId), fne.getMessage());
+            throw fne;
         } catch (Exception e) {
             LOG.info("Failed to get ledgers map index from: {}.log : {}", 
entryLogId, e.getMessage());
 

Reply via email to