Skip to content

Commit

Permalink
Bean destruction exceptions consistently logged at warn level
Browse files Browse the repository at this point in the history
Closes gh-23200
  • Loading branch information
jhoeller committed Jul 5, 2019
1 parent aeef959 commit 56cc0d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -571,8 +571,8 @@ protected void destroyBean(String beanName, @Nullable DisposableBean bean) {
bean.destroy();
}
catch (Throwable ex) {
if (logger.isInfoEnabled()) {
logger.info("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
if (logger.isWarnEnabled()) {
logger.warn("Destruction of bean with name '" + beanName + "' threw an exception", ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ public void destroy() {
catch (Throwable ex) {
String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
if (logger.isDebugEnabled()) {
logger.info(msg, ex);
logger.warn(msg, ex);
}
else {
logger.info(msg + ": " + ex);
logger.warn(msg + ": " + ex);
}
}
}
Expand Down Expand Up @@ -343,14 +343,14 @@ private void invokeCustomDestroyMethod(final Method destroyMethod) {
String msg = "Destroy method '" + this.destroyMethodName + "' on bean with name '" +
this.beanName + "' threw an exception";
if (logger.isDebugEnabled()) {
logger.info(msg, ex.getTargetException());
logger.warn(msg, ex.getTargetException());
}
else {
logger.info(msg + ": " + ex.getTargetException());
logger.warn(msg + ": " + ex.getTargetException());
}
}
catch (Throwable ex) {
logger.info("Failed to invoke destroy method '" + this.destroyMethodName +
logger.warn("Failed to invoke destroy method '" + this.destroyMethodName +
"' on bean with name '" + this.beanName + "'", ex);
}
}
Expand Down

0 comments on commit 56cc0d0

Please sign in to comment.