Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure CGLIB proxy is created for mixin with IntroductionInterceptor #31389

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -59,7 +59,7 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {

@Override
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
if (config.isOptimize() || config.isProxyTargetClass() || hashNoInterfaceImplement(config) || hasNoUserSuppliedProxyInterfaces(config)) {
Class<?> targetClass = config.getTargetClass();
if (targetClass == null) {
throw new AopConfigException("TargetSource cannot determine target class: " +
Expand All @@ -75,6 +75,12 @@ public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException
}
}

private boolean hashNoInterfaceImplement(org.springframework.aop.framework.AdvisedSupport config) {
Class<?> targetClass = config.getTargetClass();
if (targetClass == null) return false;
return targetClass.getInterfaces().length == 0;
}

Comment on lines +78 to +83
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private boolean hashNoInterfaceImplement(org.springframework.aop.framework.AdvisedSupport config) {
Class<?> targetClass = config.getTargetClass();
if (targetClass == null) return false;
return targetClass.getInterfaces().length == 0;
}
private boolean targetDoesNotImplementInterfaces(AdvisedSupport config) {
Class<?> targetClass = config.getTargetClass();
return (targetClass != null ? targetClass.getInterfaces().length == 0 : false);
}

Let's revise this method like this.

Also, please add Javadoc for this method, similar to the Javadoc for hasNoUserSuppliedProxyInterfaces(...).

/**
* Determine whether the supplied {@link AdvisedSupport} has only the
* {@link org.springframework.aop.SpringProxy} interface specified
Expand Down