From b6cfa2db0bb19bad7ea563dcc2ef65fed682b4dc Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 27 Sep 2024 19:16:05 +0200 Subject: [PATCH 1/2] Refine warn log message with advisor and ROLE_INFRASTRUCTURE hints Closes gh-33184 --- .../context/support/PostProcessorRegistrationDelegate.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java index 7735045a98..501cc17f98 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java +++ b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -437,8 +437,9 @@ final class PostProcessorRegistrationDelegate { logger.warn("Bean '" + beanName + "' of type [" + bean.getClass().getName() + "] is not eligible for getting processed by all BeanPostProcessors " + "(for example: not eligible for auto-proxying). Is this bean getting eagerly " + - "injected into a currently created BeanPostProcessor " + bppsInCreation + "? " + - "Check the corresponding BeanPostProcessor declaration and its dependencies."); + "injected/applied to a currently created BeanPostProcessor " + bppsInCreation + "? " + + "Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. " + + "If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE."); } } return bean; From 9f4968ed05a9f557d8c0bb1663a367e0ee32e479 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 27 Sep 2024 19:16:12 +0200 Subject: [PATCH 2/2] Polishing --- .../aop/framework/Advised.java | 6 ++--- .../aop/framework/AdvisedSupport.java | 24 +++++++++---------- .../context/aot/AbstractAotProcessor.java | 9 ++----- ...oProxyCreatorTests-common-interceptors.xml | 3 +-- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java b/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java index b956f00fca..968b474b26 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 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. @@ -56,9 +56,9 @@ public interface Advised extends TargetClassAware { /** * Determine whether the given interface is proxied. - * @param intf the interface to check + * @param ifc the interface to check */ - boolean isInterfaceProxied(Class intf); + boolean isInterfaceProxied(Class ifc); /** * Change the {@code TargetSource} used by this {@code Advised} object. diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java index 282d0584be..b59960864a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java @@ -222,15 +222,15 @@ public class AdvisedSupport extends ProxyConfig implements Advised { /** * Add a new proxied interface. - * @param intf the additional interface to proxy + * @param ifc the additional interface to proxy */ - public void addInterface(Class intf) { - Assert.notNull(intf, "Interface must not be null"); - if (!intf.isInterface()) { - throw new IllegalArgumentException("[" + intf.getName() + "] is not an interface"); + public void addInterface(Class ifc) { + Assert.notNull(ifc, "Interface must not be null"); + if (!ifc.isInterface()) { + throw new IllegalArgumentException("[" + ifc.getName() + "] is not an interface"); } - if (!this.interfaces.contains(intf)) { - this.interfaces.add(intf); + if (!this.interfaces.contains(ifc)) { + this.interfaces.add(ifc); adviceChanged(); } } @@ -238,12 +238,12 @@ public class AdvisedSupport extends ProxyConfig implements Advised { /** * Remove a proxied interface. *

Does nothing if the given interface isn't proxied. - * @param intf the interface to remove from the proxy + * @param ifc the interface to remove from the proxy * @return {@code true} if the interface was removed; {@code false} * if the interface was not found and hence could not be removed */ - public boolean removeInterface(Class intf) { - return this.interfaces.remove(intf); + public boolean removeInterface(Class ifc) { + return this.interfaces.remove(ifc); } @Override @@ -252,9 +252,9 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } @Override - public boolean isInterfaceProxied(Class intf) { + public boolean isInterfaceProxied(Class ifc) { for (Class proxyIntf : this.interfaces) { - if (intf.isAssignableFrom(proxyIntf)) { + if (ifc.isAssignableFrom(proxyIntf)) { return true; } } diff --git a/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java b/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java index b342e4d789..1772df8b58 100644 --- a/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java @@ -47,8 +47,7 @@ import org.springframework.util.FileSystemUtils; public abstract class AbstractAotProcessor { /** - * The name of a system property that is made available when the processor - * runs. + * The name of a system property that is made available when the processor runs. * @see #doProcess() */ private static final String AOT_PROCESSING = "spring.aot.processing"; @@ -125,6 +124,7 @@ public abstract class AbstractAotProcessor { writer.write(hints); } + /** * Common settings for AOT processors. */ @@ -140,7 +140,6 @@ public abstract class AbstractAotProcessor { private final String artifactId; - private Settings(Path sourceOutput, Path resourceOutput, Path classOutput, String groupId, String artifactId) { this.sourceOutput = sourceOutput; this.resourceOutput = resourceOutput; @@ -149,7 +148,6 @@ public abstract class AbstractAotProcessor { this.artifactId = artifactId; } - /** * Create a new {@link Builder} for {@link Settings}. */ @@ -157,7 +155,6 @@ public abstract class AbstractAotProcessor { return new Builder(); } - /** * Get the output directory for generated sources. */ @@ -214,12 +211,10 @@ public abstract class AbstractAotProcessor { @Nullable private String artifactId; - private Builder() { // internal constructor } - /** * Set the output directory for generated sources. * @param sourceOutput the location of generated sources diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml index c526e0c90f..ca75716525 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml @@ -11,7 +11,7 @@ - + nopInterceptor @@ -44,4 +44,3 @@ -