From 56cc0d02e980f3a6b1fd8dff2c10077620ea20d5 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 5 Jul 2019 17:07:22 +0200 Subject: [PATCH] Bean destruction exceptions consistently logged at warn level Closes gh-23200 --- .../factory/support/DefaultSingletonBeanRegistry.java | 6 +++--- .../beans/factory/support/DisposableBeanAdapter.java | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java index 6cec5d5014f2..185a5807631e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java @@ -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. @@ -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); } } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java index 9d1ce3466cb0..36768418cdd8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java @@ -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); } } } @@ -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); } }