This is an automated email from the ASF dual-hosted git repository. sijie pushed a commit to branch branch-4.8 in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.8 by this push: new 6705ea9 BookieWatcherImpl doesn't initCause when throwing MetaStoreException 6705ea9 is described below commit 6705ea9a7d155efece537858b15aae0745a6150f Author: Qi Wang <codingwan...@gmail.com> AuthorDate: Mon Sep 10 13:14:08 2018 -0700 BookieWatcherImpl doesn't initCause when throwing MetaStoreException Descriptions of the changes in this PR: ### Motivation when BookieWatcherImpl throws MetaStoreException, it doesn't provide the cause. so when the exception is logged, we can't tell the actual failure cause. Author: Qi Wang <codingwan...@gmail.com> Reviewers: Enrico Olivelli <eolive...@gmail.com>, Sijie Guo <si...@apache.org> This closes #1637 from codingwangqi/fill_cause_in_exception (cherry picked from commit 0446c823e36c762479cde9f69883175f8b140074) Signed-off-by: Sijie Guo <si...@apache.org> --- .../main/java/org/apache/bookkeeper/client/BKException.java | 8 ++++++++ .../main/java/org/apache/bookkeeper/client/BookieWatcher.java | 2 +- .../java/org/apache/bookkeeper/client/api/BKException.java | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BKException.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BKException.java index ddfc795..7f34f0e 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BKException.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BKException.java @@ -47,6 +47,10 @@ public abstract class BKException extends org.apache.bookkeeper.client.api.BKExc super(code); } + BKException(int code, Throwable cause) { + super(code, cause); + } + /** * Create an exception from an error code. * @param code return error code @@ -299,6 +303,10 @@ public abstract class BKException extends org.apache.bookkeeper.client.api.BKExc public MetaStoreException() { super(Code.MetaStoreException); } + + public MetaStoreException(Throwable cause) { + super(Code.MetaStoreException, cause); + } } /** diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java index d97121d..8d2bb1f 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java @@ -62,7 +62,7 @@ class BookieWatcher { log.error("Interrupted reading bookie list : ", cause); return new BKInterruptedException(); } else { - return new MetaStoreException(); + return new MetaStoreException(cause); } }; diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java index 09bb8f3..cc28158 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java @@ -60,6 +60,17 @@ public class BKException extends Exception { } /** + * Create a new exception with the <tt>cause</tt>. + * + * @param code exception code + * @param cause the exception cause + */ + public BKException(int code, Throwable cause) { + super(getMessage(code), cause); + this.code = code; + } + + /** * Get the return code for the exception. * * @return the error code