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

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


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

commit 33466e81344b21a5abb23a6157aa5536380ce3d1
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 0e2de49..7046ef5 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
@@ -57,6 +57,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));
@@ -72,7 +78,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;
         }
@@ -86,12 +92,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);
         }
     }
 
@@ -107,7 +113,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