Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -214,12 +214,15 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.warn(msg, ex);
|
||||
}
|
||||
else {
|
||||
logger.warn(msg + ": " + ex);
|
||||
if (logger.isWarnEnabled()) {
|
||||
String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
|
||||
if (logger.isDebugEnabled()) {
|
||||
// Log at warn level like below but add the exception stacktrace only with debug level
|
||||
logger.warn(msg, ex);
|
||||
}
|
||||
else {
|
||||
logger.warn(msg + ": " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,12 +243,15 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
String msg = "Invocation of close method failed on bean with name '" + this.beanName + "'";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.warn(msg, ex);
|
||||
}
|
||||
else {
|
||||
logger.warn(msg + ": " + ex);
|
||||
if (logger.isWarnEnabled()) {
|
||||
String msg = "Invocation of close method failed on bean with name '" + this.beanName + "'";
|
||||
if (logger.isDebugEnabled()) {
|
||||
// Log at warn level like below but add the exception stacktrace only with debug level
|
||||
logger.warn(msg, ex);
|
||||
}
|
||||
else {
|
||||
logger.warn(msg + ": " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,13 +326,16 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
String msg = "Custom destroy method '" + this.destroyMethodName + "' on bean with name '" +
|
||||
this.beanName + "' threw an exception";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.warn(msg, ex.getTargetException());
|
||||
}
|
||||
else {
|
||||
logger.warn(msg + ": " + ex.getTargetException());
|
||||
if (logger.isWarnEnabled()) {
|
||||
String msg = "Custom destroy method '" + this.destroyMethodName + "' on bean with name '" +
|
||||
this.beanName + "' threw an exception";
|
||||
if (logger.isDebugEnabled()) {
|
||||
// Log at warn level like below but add the exception stacktrace only with debug level
|
||||
logger.warn(msg, ex.getTargetException());
|
||||
}
|
||||
else {
|
||||
logger.warn(msg + ": " + ex.getTargetException());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
|
||||
@@ -395,6 +395,7 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("try")
|
||||
public static class ActiveResource implements AutoCloseable {
|
||||
|
||||
public ActiveResource getResource() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -263,7 +263,7 @@ public class MethodReference extends SpelNodeImpl {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
sj.add(getChild(i).toStringAST());
|
||||
}
|
||||
return this.name + sj.toString();
|
||||
return this.name + sj;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,12 +288,9 @@ public class MethodReference extends SpelNodeImpl {
|
||||
if (executor.didArgumentConversionOccur()) {
|
||||
return false;
|
||||
}
|
||||
Class<?> clazz = executor.getMethod().getDeclaringClass();
|
||||
if (!Modifier.isPublic(clazz.getModifiers()) && executor.getPublicDeclaringClass() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
Class<?> clazz = executor.getMethod().getDeclaringClass();
|
||||
return (Modifier.isPublic(clazz.getModifiers()) || executor.getPublicDeclaringClass() != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -159,11 +159,9 @@ class DefaultDatabaseClient implements DatabaseClient {
|
||||
/**
|
||||
* Release the {@link Connection}.
|
||||
* @param connection to close.
|
||||
* @return a {@link Publisher} that completes successfully when the connection is
|
||||
* closed
|
||||
* @return a {@link Publisher} that completes successfully when the connection is closed
|
||||
*/
|
||||
private Publisher<Void> closeConnection(Connection connection) {
|
||||
|
||||
return ConnectionFactoryUtils.currentConnectionFactory(
|
||||
obtainConnectionFactory()).then().onErrorResume(Exception.class,
|
||||
e -> Mono.from(connection.close()));
|
||||
@@ -189,24 +187,22 @@ class DefaultDatabaseClient implements DatabaseClient {
|
||||
new CloseSuppressingInvocationHandler(con));
|
||||
}
|
||||
|
||||
private static Mono<Integer> sumRowsUpdated(
|
||||
Function<Connection, Flux<Result>> resultFunction, Connection it) {
|
||||
private static Mono<Integer> sumRowsUpdated(Function<Connection, Flux<Result>> resultFunction, Connection it) {
|
||||
return resultFunction.apply(it)
|
||||
.flatMap(Result::getRowsUpdated)
|
||||
.collect(Collectors.summingInt(Integer::intValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine SQL from potential provider object.
|
||||
* @param sqlProvider object that's potentially a SqlProvider
|
||||
* Get SQL from a potential provider object.
|
||||
* @param object an object that is potentially an SqlProvider
|
||||
* @return the SQL string, or {@code null}
|
||||
* @see SqlProvider
|
||||
*/
|
||||
@Nullable
|
||||
private static String getSql(Object sqlProvider) {
|
||||
|
||||
if (sqlProvider instanceof SqlProvider) {
|
||||
return ((SqlProvider) sqlProvider).getSql();
|
||||
private static String getSql(Object object) {
|
||||
if (object instanceof SqlProvider) {
|
||||
return ((SqlProvider) object).getSql();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@@ -215,7 +211,7 @@ class DefaultDatabaseClient implements DatabaseClient {
|
||||
|
||||
|
||||
/**
|
||||
* Base class for {@link DatabaseClient.GenericExecuteSpec} implementations.
|
||||
* Default {@link DatabaseClient.GenericExecuteSpec} implementation.
|
||||
*/
|
||||
class DefaultGenericExecuteSpec implements GenericExecuteSpec {
|
||||
|
||||
@@ -505,12 +501,11 @@ class DefaultDatabaseClient implements DatabaseClient {
|
||||
|
||||
private static final long serialVersionUID = -8994138383301201380L;
|
||||
|
||||
final Connection connection;
|
||||
final transient Connection connection;
|
||||
|
||||
final Function<Connection, Publisher<Void>> closeFunction;
|
||||
final transient Function<Connection, Publisher<Void>> closeFunction;
|
||||
|
||||
ConnectionCloseHolder(Connection connection,
|
||||
Function<Connection, Publisher<Void>> closeFunction) {
|
||||
ConnectionCloseHolder(Connection connection, Function<Connection, Publisher<Void>> closeFunction) {
|
||||
this.connection = connection;
|
||||
this.closeFunction = closeFunction;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,7 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
|
||||
.as(chunks -> ReactiveRequest.Content.fromPublisher(chunks, getContentType()));
|
||||
this.builder.content(content);
|
||||
sink.success();
|
||||
})
|
||||
.then(doCommit());
|
||||
}).then(doCommit());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -279,6 +279,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
*/
|
||||
private static final String DEFAULT_STRATEGIES_PREFIX = "org.springframework.web.servlet";
|
||||
|
||||
|
||||
/** Additional logger to use when no mapped handler is found for a request. */
|
||||
protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user