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

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


The following commit(s) were added to refs/heads/branch-4.10 by this push:
     new cdec1bb  Fixed: DLCheckpointStore rethrows exceptions as FNFE but 
swallows the rootcause
cdec1bb is described below

commit cdec1bbb37e225248a6bb1603f35cc66943546d4
Author: Andrey Yegorov <[email protected]>
AuthorDate: Thu Jan 28 00:12:05 2021 -0800

    Fixed: DLCheckpointStore rethrows exceptions as FNFE but swallows the 
rootcause
    
    DLCheckpointStore rethrows exceptions as FNFE but swallows the rootcause
    Same as https://github.com/apache/bookkeeper/pull/2553 but for master branch
    
    Descriptions of the changes in this PR:
    
    added .initCause for the new FNFE exception to preserver it
    
    ### Motivation
    
    got the
    ERROR 
org.apache.bookkeeper.statelib.impl.rocksdb.checkpoint.RocksCheckpointer - 
Failed to restore rocksdb ...
    java.io.FileNotFoundException: ..../metadata
    without any additional info for the rootcause (other than stack pointing to 
the DLCheckpointStore)
    
    DLCheckpointStore appears to re-throw exceptions as FNFE without preserving 
the rootcause
    
    ### Changes
    
    added .initCause
    
    Master Issue: #2552
    
    Reviewers: Enrico Olivelli <[email protected]>
    
    This closes #2555 from dlg99/master-fnfe
    
    (cherry picked from commit bab5a003e84601469485cbcee4fc784171a1513d)
    Signed-off-by: Enrico Olivelli <[email protected]>
---
 .../impl/rocksdb/checkpoint/dlog/DLCheckpointStore.java    | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLCheckpointStore.java
 
b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLCheckpointStore.java
index 8dc0447..bf36b9f 100644
--- 
a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLCheckpointStore.java
+++ 
b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/rocksdb/checkpoint/dlog/DLCheckpointStore.java
@@ -55,6 +55,12 @@ public class DLCheckpointStore implements CheckpointStore {
         this.namespace = namespace;
     }
 
+    private static FileNotFoundException createFileNotFoundException(String 
filePath, Throwable t) {
+        FileNotFoundException fnfe = new FileNotFoundException(filePath);
+        fnfe.initCause(t);
+        return fnfe;
+    }
+
     @Override
     public List<String> listFiles(String filePath) throws IOException {
         return Lists.newArrayList(namespace.getLogs(filePath));
@@ -70,7 +76,7 @@ public class DLCheckpointStore implements CheckpointStore {
         try (DistributedLogManager dlm = namespace.openLog(filePath)) {
             return dlm.getLastTxId();
         } catch (LogNotFoundException e) {
-            throw new FileNotFoundException(filePath);
+            throw createFileNotFoundException(filePath, e);
         } catch (LogEmptyException e) {
             return 0;
         }
@@ -84,12 +90,12 @@ public class DLCheckpointStore implements CheckpointStore {
             try {
                 reader = dlm.openLogReader(DLSN.InitialDLSN);
             } catch (LogNotFoundException | LogEmptyException e) {
-                throw new FileNotFoundException(filePath);
+                throw createFileNotFoundException(filePath, e);
             }
             return new BufferedInputStream(
                 new DLInputStream(dlm, reader, 0L), 128 * 1024);
         } catch (LogNotFoundException e) {
-            throw new FileNotFoundException(filePath);
+            throw createFileNotFoundException(filePath, e);
         }
     }
 
@@ -102,7 +108,7 @@ public class DLCheckpointStore implements CheckpointStore {
             return new BufferedOutputStream(
                 new DLOutputStream(dlm, writer), 128 * 1024);
         } catch (LogNotFoundException le) {
-            throw new FileNotFoundException(filePath);
+            throw createFileNotFoundException(filePath, le);
         }
     }
 

Reply via email to