Browse Source

Polishing

pull/29918/head
Juergen Hoeller 2 years ago
parent
commit
c0c9ba5c2c
  1. 7
      spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java
  2. 17
      spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java
  3. 4
      spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java
  4. 6
      spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
  5. 4
      spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java
  6. 5
      spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpRequest.java
  7. 1
      spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

7
spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java

@ -93,12 +93,13 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu @@ -93,12 +93,13 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
if (bean instanceof Advised advised) {
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) {
advised.addAdvisor(0, this.advisor);
}
else if (advised.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE && advised.getAdvisorCount() > 0) {
// No target, leave last advisor in place
else if (advised.getTargetSource() == AdvisedSupport.EMPTY_TARGET_SOURCE &&
advised.getAdvisorCount() > 0) {
// No target, leave last Advisor in place and add new Advisor right before.
advised.addAdvisor(advised.getAdvisorCount() - 1, this.advisor);
return bean;
}

17
spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

@ -1,5 +1,5 @@ @@ -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.
@ -200,12 +200,15 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { @@ -200,12 +200,15 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
((DisposableBean) this.bean).destroy();
}
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);
}
}
}
}

4
spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java

@ -1,5 +1,5 @@ @@ -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.
@ -261,7 +261,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe @@ -261,7 +261,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
return new Object[] {event};
}
@SuppressWarnings({ "deprecation", "unchecked" })
@SuppressWarnings({"deprecation", "unchecked"})
protected void handleResult(Object result) {
if (reactiveStreamsPresent && new ReactiveResultHandler().subscribeToPublisher(result)) {
if (logger.isTraceEnabled()) {

6
spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java

@ -263,7 +263,7 @@ public class MethodReference extends SpelNodeImpl { @@ -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;
}
/**
@ -283,12 +283,12 @@ public class MethodReference extends SpelNodeImpl { @@ -283,12 +283,12 @@ public class MethodReference extends SpelNodeImpl {
return false;
}
}
if (executor.didArgumentConversionOccur()) {
return false;
}
Class<?> clazz = executor.getMethod().getDeclaringClass();
return Modifier.isPublic(clazz.getModifiers()) || executor.getPublicDeclaringClass() != null;
return (Modifier.isPublic(clazz.getModifiers()) || executor.getPublicDeclaringClass() != null);
}
@Override

4
spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java

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

5
spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpRequest.java

@ -1,5 +1,5 @@ @@ -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.
@ -94,8 +94,7 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest { @@ -94,8 +94,7 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
.as(chunks -> ReactiveRequest.Content.fromPublisher(chunks, getContentType()));
this.builder.content(content);
sink.success();
})
.then(doCommit());
}).then(doCommit());
}
@Override

1
spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

@ -284,6 +284,7 @@ public class DispatcherServlet extends FrameworkServlet { @@ -284,6 +284,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);

Loading…
Cancel
Save