|
|
|
@ -221,12 +221,15 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { |
|
|
|
((AutoCloseable) this.bean).close(); |
|
|
|
((AutoCloseable) this.bean).close(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Throwable ex) { |
|
|
|
catch (Throwable ex) { |
|
|
|
String msg = "Invocation of close method failed on bean with name '" + this.beanName + "'"; |
|
|
|
if (logger.isWarnEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
String msg = "Invocation of close method failed on bean with name '" + this.beanName + "'"; |
|
|
|
logger.warn(msg, ex); |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
} |
|
|
|
// Log at warn level like below but add the exception stacktrace only with debug level
|
|
|
|
else { |
|
|
|
logger.warn(msg, ex); |
|
|
|
logger.warn(msg + ": " + ex); |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
logger.warn(msg + ": " + ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -286,18 +289,23 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { |
|
|
|
destroyMethod.invoke(this.bean, args); |
|
|
|
destroyMethod.invoke(this.bean, args); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (InvocationTargetException ex) { |
|
|
|
catch (InvocationTargetException ex) { |
|
|
|
String msg = "Custom destroy method '" + destroyMethod.getName() + "' on bean with name '" + |
|
|
|
if (logger.isWarnEnabled()) { |
|
|
|
this.beanName + "' threw an exception"; |
|
|
|
String msg = "Custom destroy method '" + destroyMethod.getName() + "' on bean with name '" + |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
this.beanName + "' threw an exception"; |
|
|
|
logger.warn(msg, ex.getTargetException()); |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
} |
|
|
|
// Log at warn level like below but add the exception stacktrace only with debug level
|
|
|
|
else { |
|
|
|
logger.warn(msg, ex.getTargetException()); |
|
|
|
logger.warn(msg + ": " + ex.getTargetException()); |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
logger.warn(msg + ": " + ex.getTargetException()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Throwable ex) { |
|
|
|
catch (Throwable ex) { |
|
|
|
logger.warn("Failed to invoke custom destroy method '" + destroyMethod.getName() + |
|
|
|
if (logger.isWarnEnabled()) { |
|
|
|
"' on bean with name '" + this.beanName + "'", ex); |
|
|
|
logger.warn("Failed to invoke custom destroy method '" + destroyMethod.getName() + |
|
|
|
|
|
|
|
"' on bean with name '" + this.beanName + "'", ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -328,8 +336,8 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { |
|
|
|
* @param beanDefinition the corresponding bean definition |
|
|
|
* @param beanDefinition the corresponding bean definition |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static boolean hasDestroyMethod(Object bean, RootBeanDefinition beanDefinition) { |
|
|
|
public static boolean hasDestroyMethod(Object bean, RootBeanDefinition beanDefinition) { |
|
|
|
return (bean instanceof DisposableBean |
|
|
|
return (bean instanceof DisposableBean || |
|
|
|
|| inferDestroyMethodsIfNecessary(bean.getClass(), beanDefinition) != null); |
|
|
|
inferDestroyMethodsIfNecessary(bean.getClass(), beanDefinition) != null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|