Polishing
This commit is contained in:
parent
c0c9ba5c2c
commit
16937c7ce5
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -244,8 +244,8 @@ class DefaultDatabaseClient implements DatabaseClient {
|
||||||
this.filterFunction = filterFunction;
|
this.filterFunction = filterFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
public DefaultGenericExecuteSpec bind(int index, Object value) {
|
public DefaultGenericExecuteSpec bind(int index, Object value) {
|
||||||
assertNotPreparedOperation();
|
assertNotPreparedOperation();
|
||||||
Assert.notNull(value, () -> String.format(
|
Assert.notNull(value, () -> String.format(
|
||||||
|
|
@ -275,8 +275,8 @@ class DefaultDatabaseClient implements DatabaseClient {
|
||||||
return new DefaultGenericExecuteSpec(byIndex, this.byName, this.sqlSupplier, this.filterFunction);
|
return new DefaultGenericExecuteSpec(byIndex, this.byName, this.sqlSupplier, this.filterFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
public DefaultGenericExecuteSpec bind(String name, Object value) {
|
public DefaultGenericExecuteSpec bind(String name, Object value) {
|
||||||
assertNotPreparedOperation();
|
assertNotPreparedOperation();
|
||||||
|
|
||||||
|
|
@ -522,8 +522,7 @@ class DefaultDatabaseClient implements DatabaseClient {
|
||||||
|
|
||||||
final transient Function<Connection, Publisher<Void>> closeFunction;
|
final transient Function<Connection, Publisher<Void>> closeFunction;
|
||||||
|
|
||||||
ConnectionCloseHolder(Connection connection,
|
ConnectionCloseHolder(Connection connection, Function<Connection, Publisher<Void>> closeFunction) {
|
||||||
Function<Connection, Publisher<Void>> closeFunction) {
|
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.closeFunction = closeFunction;
|
this.closeFunction = closeFunction;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue