Polishing

This commit is contained in:
Juergen Hoeller
2023-01-31 16:14:32 +01:00
parent 4d6249811e
commit c0c9ba5c2c
7 changed files with 23 additions and 21 deletions

View File

@@ -93,12 +93,13 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
if (bean instanceof Advised advised) { if (bean instanceof Advised advised) {
if (!advised.isFrozen() && isEligible(AopUtils.getTargetClass(bean))) { if (!advised.isFrozen() && isEligible(AopUtils.getTargetClass(bean))) {
// Add our local Advisor to the existing proxy's Advisor chain... // Add our local Advisor to the existing proxy's Advisor chain.
if (this.beforeExistingAdvisors) { if (this.beforeExistingAdvisors) {
advised.addAdvisor(0, this.advisor); advised.addAdvisor(0, this.advisor);
} }
else if (advised.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE && advised.getAdvisorCount() > 0) { else if (advised.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE &&
// No target, leave last advisor in place advised.getAdvisorCount() > 0) {
// No target, leave last Advisor in place and add new Advisor right before.
advised.addAdvisor(advised.getAdvisorCount() - 1, this.advisor); advised.addAdvisor(advised.getAdvisorCount() - 1, this.advisor);
return bean; return bean;
} }

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -200,12 +200,15 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
((DisposableBean) this.bean).destroy(); ((DisposableBean) this.bean).destroy();
} }
catch (Throwable ex) { catch (Throwable ex) {
String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'"; if (logger.isWarnEnabled()) {
if (logger.isDebugEnabled()) { String msg = "Invocation of destroy 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);
}
} }
} }
} }

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -261,7 +261,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
return new Object[] {event}; return new Object[] {event};
} }
@SuppressWarnings({ "deprecation", "unchecked" }) @SuppressWarnings({"deprecation", "unchecked"})
protected void handleResult(Object result) { protected void handleResult(Object result) {
if (reactiveStreamsPresent && new ReactiveResultHandler().subscribeToPublisher(result)) { if (reactiveStreamsPresent && new ReactiveResultHandler().subscribeToPublisher(result)) {
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {

View File

@@ -263,7 +263,7 @@ public class MethodReference extends SpelNodeImpl {
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
sj.add(getChild(i).toStringAST()); sj.add(getChild(i).toStringAST());
} }
return this.name + sj.toString(); return this.name + sj;
} }
/** /**
@@ -283,12 +283,12 @@ public class MethodReference extends SpelNodeImpl {
return false; return false;
} }
} }
if (executor.didArgumentConversionOccur()) { if (executor.didArgumentConversionOccur()) {
return false; return false;
} }
Class<?> clazz = executor.getMethod().getDeclaringClass(); Class<?> clazz = executor.getMethod().getDeclaringClass();
return Modifier.isPublic(clazz.getModifiers()) || executor.getPublicDeclaringClass() != null; return (Modifier.isPublic(clazz.getModifiers()) || executor.getPublicDeclaringClass() != null);
} }
@Override @Override

View File

@@ -166,7 +166,6 @@ class DefaultDatabaseClient implements DatabaseClient {
* closed * closed
*/ */
private Publisher<Void> closeConnection(Connection connection) { private Publisher<Void> closeConnection(Connection connection) {
return ConnectionFactoryUtils.currentConnectionFactory( return ConnectionFactoryUtils.currentConnectionFactory(
obtainConnectionFactory()).then().onErrorResume(Exception.class, obtainConnectionFactory()).then().onErrorResume(Exception.class,
e -> Mono.from(connection.close())); e -> Mono.from(connection.close()));
@@ -192,8 +191,7 @@ class DefaultDatabaseClient implements DatabaseClient {
new CloseSuppressingInvocationHandler(con)); new CloseSuppressingInvocationHandler(con));
} }
private static Mono<Long> sumRowsUpdated( private static Mono<Long> sumRowsUpdated(Function<Connection, Flux<Result>> resultFunction, Connection it) {
Function<Connection, Flux<Result>> resultFunction, Connection it) {
return resultFunction.apply(it) return resultFunction.apply(it)
.flatMap(Result::getRowsUpdated) .flatMap(Result::getRowsUpdated)
.cast(Number.class) .cast(Number.class)

View File

@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -94,8 +94,7 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
.as(chunks -> ReactiveRequest.Content.fromPublisher(chunks, getContentType())); .as(chunks -> ReactiveRequest.Content.fromPublisher(chunks, getContentType()));
this.builder.content(content); this.builder.content(content);
sink.success(); sink.success();
}) }).then(doCommit());
.then(doCommit());
} }
@Override @Override

View File

@@ -284,6 +284,7 @@ public class DispatcherServlet extends FrameworkServlet {
*/ */
private static final String DEFAULT_STRATEGIES_PREFIX = "org.springframework.web.servlet"; private static final String DEFAULT_STRATEGIES_PREFIX = "org.springframework.web.servlet";
/** Additional logger to use when no mapped handler is found for a request. */ /** 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); protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);