Skip to content

Commit 56cc0d0

Browse files
committed
Bean destruction exceptions consistently logged at warn level
Closes gh-23200
1 parent aeef959 commit 56cc0d0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -571,8 +571,8 @@ protected void destroyBean(String beanName, @Nullable DisposableBean bean) {
571571
bean.destroy();
572572
}
573573
catch (Throwable ex) {
574-
if (logger.isInfoEnabled()) {
575-
logger.info("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
574+
if (logger.isWarnEnabled()) {
575+
logger.warn("Destruction of bean with name '" + beanName + "' threw an exception", ex);
576576
}
577577
}
578578
}

spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ public void destroy() {
261261
catch (Throwable ex) {
262262
String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
263263
if (logger.isDebugEnabled()) {
264-
logger.info(msg, ex);
264+
logger.warn(msg, ex);
265265
}
266266
else {
267-
logger.info(msg + ": " + ex);
267+
logger.warn(msg + ": " + ex);
268268
}
269269
}
270270
}
@@ -343,14 +343,14 @@ private void invokeCustomDestroyMethod(final Method destroyMethod) {
343343
String msg = "Destroy method '" + this.destroyMethodName + "' on bean with name '" +
344344
this.beanName + "' threw an exception";
345345
if (logger.isDebugEnabled()) {
346-
logger.info(msg, ex.getTargetException());
346+
logger.warn(msg, ex.getTargetException());
347347
}
348348
else {
349-
logger.info(msg + ": " + ex.getTargetException());
349+
logger.warn(msg + ": " + ex.getTargetException());
350350
}
351351
}
352352
catch (Throwable ex) {
353-
logger.info("Failed to invoke destroy method '" + this.destroyMethodName +
353+
logger.warn("Failed to invoke destroy method '" + this.destroyMethodName +
354354
"' on bean with name '" + this.beanName + "'", ex);
355355
}
356356
}

0 commit comments

Comments
 (0)