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 1cf8fba4150b84a06c176b0254bf74afd4a8d62d Author: houxiaoyu <[email protected]> AuthorDate: Tue Aug 29 14:53:29 2023 +0800 fix AutoCloseableLifecycleComponent close exception log (#4042) Descriptions of the changes in this PR: ### Motivation If closed with exception, the log will always be `failed to close AutoCloseableLifecycleComponent`. It will be better to print the `componentName` instead of the class name. ### Changes Print the `componentName` instead of `AutoCloseableLifecycleComponent` class name if closed with exception (cherry picked from commit 269374fe5318a435c0591cc462af63ead61f3f8c) --- .../apache/bookkeeper/common/component/AbstractLifecycleComponent.java | 2 +- .../bookkeeper/common/component/AutoCloseableLifecycleComponent.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AbstractLifecycleComponent.java b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AbstractLifecycleComponent.java index 5b6f19ee35..534c952f33 100644 --- a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AbstractLifecycleComponent.java +++ b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AbstractLifecycleComponent.java @@ -122,7 +122,7 @@ public abstract class AbstractLifecycleComponent<ConfT extends ComponentConfigur try { doClose(); } catch (IOException e) { - log.warn("failed to close {}", getClass().getName(), e); + log.warn("failed to close {}", componentName, e); } listeners.forEach(LifecycleListener::afterClose); } diff --git a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AutoCloseableLifecycleComponent.java b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AutoCloseableLifecycleComponent.java index 933b0aaf0d..39b574d631 100644 --- a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AutoCloseableLifecycleComponent.java +++ b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/AutoCloseableLifecycleComponent.java @@ -99,7 +99,7 @@ public class AutoCloseableLifecycleComponent implements LifecycleComponent { try { closeable.close(); } catch (Exception e) { - LOG.warn("failed to close {}", getClass().getName(), e); + LOG.warn("failed to close {}", componentName, e); } listeners.forEach(LifecycleListener::afterClose); }
