Apply "instanceof pattern matching" in spring-aop

This commit is contained in:
Sam Brannen 2022-12-18 14:12:08 +01:00
parent ab571e3562
commit b71db12c43
38 changed files with 160 additions and 161 deletions

View File

@ -655,10 +655,10 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
@Nullable @Nullable
protected JoinPointMatch getJoinPointMatch() { protected JoinPointMatch getJoinPointMatch() {
MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation(); MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
if (!(mi instanceof ProxyMethodInvocation)) { if (!(mi instanceof ProxyMethodInvocation pmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
} }
return getJoinPointMatch((ProxyMethodInvocation) mi); return getJoinPointMatch(pmi);
} }
// Note: We can't use JoinPointMatch.getClass().getName() as the key, since // Note: We can't use JoinPointMatch.getClass().getName() as the key, since

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2022 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.
@ -61,12 +61,12 @@ public abstract class AspectJAopUtils {
*/ */
@Nullable @Nullable
public static AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) { public static AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) {
if (anAdvisor instanceof AspectJPrecedenceInformation) { if (anAdvisor instanceof AspectJPrecedenceInformation ajpi) {
return (AspectJPrecedenceInformation) anAdvisor; return ajpi;
} }
Advice advice = anAdvisor.getAdvice(); Advice advice = anAdvisor.getAdvice();
if (advice instanceof AspectJPrecedenceInformation) { if (advice instanceof AspectJPrecedenceInformation ajpi) {
return (AspectJPrecedenceInformation) advice; return ajpi;
} }
return null; return null;
} }

View File

@ -200,8 +200,8 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
*/ */
@Nullable @Nullable
private ClassLoader determinePointcutClassLoader() { private ClassLoader determinePointcutClassLoader() {
if (this.beanFactory instanceof ConfigurableBeanFactory) { if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader(); return cbf.getBeanClassLoader();
} }
if (this.pointcutDeclarationScope != null) { if (this.pointcutDeclarationScope != null) {
return this.pointcutDeclarationScope.getClassLoader(); return this.pointcutDeclarationScope.getClassLoader();
@ -335,10 +335,10 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
try { try {
MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation(); MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
targetObject = mi.getThis(); targetObject = mi.getThis();
if (!(mi instanceof ProxyMethodInvocation)) { if (!(mi instanceof ProxyMethodInvocation _pmi)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
} }
pmi = (ProxyMethodInvocation) mi; pmi = _pmi;
thisObject = pmi.getProxy(); thisObject = pmi.getProxy();
} }
catch (IllegalStateException ex) { catch (IllegalStateException ex) {
@ -404,8 +404,8 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
} }
private RuntimeTestWalker getRuntimeTestWalker(ShadowMatch shadowMatch) { private RuntimeTestWalker getRuntimeTestWalker(ShadowMatch shadowMatch) {
if (shadowMatch instanceof DefensiveShadowMatch) { if (shadowMatch instanceof DefensiveShadowMatch defensiveShadowMatch) {
return new RuntimeTestWalker(((DefensiveShadowMatch) shadowMatch).primary); return new RuntimeTestWalker(defensiveShadowMatch.primary);
} }
return new RuntimeTestWalker(shadowMatch); return new RuntimeTestWalker(shadowMatch);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@ -71,8 +71,8 @@ public abstract class AspectJProxyUtils {
private static boolean isAspectJAdvice(Advisor advisor) { private static boolean isAspectJAdvice(Advisor advisor) {
return (advisor instanceof InstantiationModelAwarePointcutAdvisor || return (advisor instanceof InstantiationModelAwarePointcutAdvisor ||
advisor.getAdvice() instanceof AbstractAspectJAdvice || advisor.getAdvice() instanceof AbstractAspectJAdvice ||
(advisor instanceof PointcutAdvisor && (advisor instanceof PointcutAdvisor pointcutAdvisor &&
((PointcutAdvisor) advisor).getPointcut() instanceof AspectJExpressionPointcut)); pointcutAdvisor.getPointcut() instanceof AspectJExpressionPointcut));
} }
static boolean isVariableName(@Nullable String name) { static boolean isVariableName(@Nullable String name) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2022 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.
@ -202,8 +202,8 @@ class RuntimeTestWalker {
} }
Class<?> typeClass = null; Class<?> typeClass = null;
ResolvedType type = (ResolvedType) i.getType(); ResolvedType type = (ResolvedType) i.getType();
if (type instanceof ReferenceType) { if (type instanceof ReferenceType referenceType) {
ReferenceTypeDelegate delegate = ((ReferenceType) type).getDelegate(); ReferenceTypeDelegate delegate = referenceType.getDelegate();
if (delegate instanceof ReflectionBasedReferenceTypeDelegate) { if (delegate instanceof ReflectionBasedReferenceTypeDelegate) {
try { try {
ReflectionUtils.makeAccessible(myClassField); ReflectionUtils.makeAccessible(myClassField);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2022 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.
@ -69,8 +69,8 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory, Se
*/ */
@Override @Override
public int getOrder() { public int getOrder() {
if (this.aspectInstance instanceof Ordered) { if (this.aspectInstance instanceof Ordered ordered) {
return ((Ordered) this.aspectInstance).getOrder(); return ordered.getOrder();
} }
return getOrderForAspectClass(this.aspectInstance.getClass()); return getOrderForAspectClass(this.aspectInstance.getClass());
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 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.
@ -117,9 +117,9 @@ public class TypePatternClassFilter implements ClassFilter {
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object obj) {
return (this == other || (other instanceof TypePatternClassFilter && return (this == obj || (obj instanceof TypePatternClassFilter that &&
ObjectUtils.nullSafeEquals(this.typePattern, ((TypePatternClassFilter) other).typePattern))); ObjectUtils.nullSafeEquals(this.typePattern, that.typePattern)));
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2022 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.
@ -93,9 +93,8 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
@Override @Override
@Nullable @Nullable
public ClassLoader getAspectClassLoader() { public ClassLoader getAspectClassLoader() {
return (this.beanFactory instanceof ConfigurableBeanFactory ? return (this.beanFactory instanceof ConfigurableBeanFactory cbf ?
((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader() : cbf.getBeanClassLoader() : ClassUtils.getDefaultClassLoader());
ClassUtils.getDefaultClassLoader());
} }
@Override @Override
@ -110,11 +109,11 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
// Rely on singleton semantics provided by the factory -> no local lock. // Rely on singleton semantics provided by the factory -> no local lock.
return null; return null;
} }
else if (this.beanFactory instanceof ConfigurableBeanFactory) { else if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
// No singleton guarantees from the factory -> let's lock locally but // No singleton guarantees from the factory -> let's lock locally but
// reuse the factory's singleton lock, just in case a lazy dependency // reuse the factory's singleton lock, just in case a lazy dependency
// of our advice bean happens to trigger the singleton lock implicitly... // of our advice bean happens to trigger the singleton lock implicitly...
return ((ConfigurableBeanFactory) this.beanFactory).getSingletonMutex(); return cbf.getSingletonMutex();
} }
else { else {
return this; return this;

View File

@ -274,8 +274,8 @@ final class InstantiationModelAwarePointcutAdvisorImpl
this.declaredPointcut = declaredPointcut; this.declaredPointcut = declaredPointcut;
this.preInstantiationPointcut = preInstantiationPointcut; this.preInstantiationPointcut = preInstantiationPointcut;
if (aspectInstanceFactory instanceof LazySingletonAspectInstanceFactoryDecorator) { if (aspectInstanceFactory instanceof LazySingletonAspectInstanceFactoryDecorator lazyFactory) {
this.aspectInstanceFactory = (LazySingletonAspectInstanceFactoryDecorator) aspectInstanceFactory; this.aspectInstanceFactory = lazyFactory;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2022 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.
@ -93,8 +93,8 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
// copy autowire settings from original bean definition. // copy autowire settings from original bean definition.
proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate()); proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate());
proxyDefinition.setPrimary(targetDefinition.isPrimary()); proxyDefinition.setPrimary(targetDefinition.isPrimary());
if (targetDefinition instanceof AbstractBeanDefinition) { if (targetDefinition instanceof AbstractBeanDefinition abd) {
proxyDefinition.copyQualifiersFrom((AbstractBeanDefinition) targetDefinition); proxyDefinition.copyQualifiersFrom(abd);
} }
// wrap it in a BeanDefinitionHolder with bean name // wrap it in a BeanDefinitionHolder with bean name
result = new BeanDefinitionHolder(proxyDefinition, existingBeanName); result = new BeanDefinitionHolder(proxyDefinition, existingBeanName);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@ -153,13 +153,13 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
Object pointcut = parsePointcutProperty(advisorElement, parserContext); Object pointcut = parsePointcutProperty(advisorElement, parserContext);
if (pointcut instanceof BeanDefinition) { if (pointcut instanceof BeanDefinition beanDefinition) {
advisorDef.getPropertyValues().add(POINTCUT, pointcut); advisorDef.getPropertyValues().add(POINTCUT, pointcut);
parserContext.registerComponent( parserContext.registerComponent(
new AdvisorComponentDefinition(advisorBeanName, advisorDef, (BeanDefinition) pointcut)); new AdvisorComponentDefinition(advisorBeanName, advisorDef, beanDefinition));
} }
else if (pointcut instanceof String) { else if (pointcut instanceof String beanName) {
advisorDef.getPropertyValues().add(POINTCUT, new RuntimeBeanReference((String) pointcut)); advisorDef.getPropertyValues().add(POINTCUT, new RuntimeBeanReference(beanName));
parserContext.registerComponent( parserContext.registerComponent(
new AdvisorComponentDefinition(advisorBeanName, advisorDef)); new AdvisorComponentDefinition(advisorBeanName, advisorDef));
} }
@ -389,12 +389,12 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
cav.addIndexedArgumentValue(METHOD_INDEX, methodDef); cav.addIndexedArgumentValue(METHOD_INDEX, methodDef);
Object pointcut = parsePointcutProperty(adviceElement, parserContext); Object pointcut = parsePointcutProperty(adviceElement, parserContext);
if (pointcut instanceof BeanDefinition) { if (pointcut instanceof BeanDefinition beanDefinition) {
cav.addIndexedArgumentValue(POINTCUT_INDEX, pointcut); cav.addIndexedArgumentValue(POINTCUT_INDEX, pointcut);
beanDefinitions.add((BeanDefinition) pointcut); beanDefinitions.add(beanDefinition);
} }
else if (pointcut instanceof String) { else if (pointcut instanceof String beanName) {
RuntimeBeanReference pointcutRef = new RuntimeBeanReference((String) pointcut); RuntimeBeanReference pointcutRef = new RuntimeBeanReference(beanName);
cav.addIndexedArgumentValue(POINTCUT_INDEX, pointcutRef); cav.addIndexedArgumentValue(POINTCUT_INDEX, pointcutRef);
beanReferences.add(pointcutRef); beanReferences.add(pointcutRef);
} }

View File

@ -71,8 +71,8 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
@Override @Override
@Nullable @Nullable
public ClassLoader getAspectClassLoader() { public ClassLoader getAspectClassLoader() {
if (this.beanFactory instanceof ConfigurableBeanFactory) { if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader(); return cbf.getBeanClassLoader();
} }
else { else {
return ClassUtils.getDefaultClassLoader(); return ClassUtils.getDefaultClassLoader();

View File

@ -74,8 +74,9 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
// Use original ClassLoader if bean class not locally loaded in overriding class loader // Use original ClassLoader if bean class not locally loaded in overriding class loader
ClassLoader classLoader = getProxyClassLoader(); ClassLoader classLoader = getProxyClassLoader();
if (classLoader instanceof SmartClassLoader && classLoader != beanClass.getClassLoader()) { if (classLoader instanceof SmartClassLoader smartClassLoader &&
classLoader = ((SmartClassLoader) classLoader).getOriginalClassLoader(); classLoader != beanClass.getClassLoader()) {
classLoader = smartClassLoader.getOriginalClassLoader();
} }
return proxyFactory.getProxyClass(classLoader); return proxyFactory.getProxyClass(classLoader);
} }
@ -113,8 +114,9 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
// Use original ClassLoader if bean class not locally loaded in overriding class loader // Use original ClassLoader if bean class not locally loaded in overriding class loader
ClassLoader classLoader = getProxyClassLoader(); ClassLoader classLoader = getProxyClassLoader();
if (classLoader instanceof SmartClassLoader && classLoader != bean.getClass().getClassLoader()) { if (classLoader instanceof SmartClassLoader smartClassLoader &&
classLoader = ((SmartClassLoader) classLoader).getOriginalClassLoader(); classLoader != bean.getClass().getClassLoader()) {
classLoader = smartClassLoader.getOriginalClassLoader();
} }
return proxyFactory.getProxy(classLoader); return proxyFactory.getProxy(classLoader);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2022 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.
@ -194,8 +194,8 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
* @return a TargetSource for this object * @return a TargetSource for this object
*/ */
protected TargetSource createTargetSource(Object target) { protected TargetSource createTargetSource(Object target) {
if (target instanceof TargetSource) { if (target instanceof TargetSource targetSource) {
return (TargetSource) target; return targetSource;
} }
else { else {
return new SingletonTargetSource(target); return new SingletonTargetSource(target);
@ -229,8 +229,8 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
if (this.proxyInterfaces != null && this.proxyInterfaces.length == 1) { if (this.proxyInterfaces != null && this.proxyInterfaces.length == 1) {
return this.proxyInterfaces[0]; return this.proxyInterfaces[0];
} }
if (this.target instanceof TargetSource) { if (this.target instanceof TargetSource targetSource) {
return ((TargetSource) this.target).getTargetClass(); return targetSource.getTargetClass();
} }
if (this.target != null) { if (this.target != null) {
return this.target.getClass(); return this.target.getClass();

View File

@ -258,8 +258,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override @Override
public void addAdvisor(int pos, Advisor advisor) throws AopConfigException { public void addAdvisor(int pos, Advisor advisor) throws AopConfigException {
if (advisor instanceof IntroductionAdvisor) { if (advisor instanceof IntroductionAdvisor introductionAdvisor) {
validateIntroductionAdvisor((IntroductionAdvisor) advisor); validateIntroductionAdvisor(introductionAdvisor);
} }
addAdvisorInternal(pos, advisor); addAdvisorInternal(pos, advisor);
} }
@ -287,9 +287,9 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
Advisor advisor = this.advisors.remove(index); Advisor advisor = this.advisors.remove(index);
if (advisor instanceof IntroductionAdvisor ia) { if (advisor instanceof IntroductionAdvisor introductionAdvisor) {
// We need to remove introduction interfaces. // We need to remove introduction interfaces.
for (Class<?> ifc : ia.getInterfaces()) { for (Class<?> ifc : introductionAdvisor.getInterfaces()) {
removeInterface(ifc); removeInterface(ifc);
} }
} }
@ -387,10 +387,10 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override @Override
public void addAdvice(int pos, Advice advice) throws AopConfigException { public void addAdvice(int pos, Advice advice) throws AopConfigException {
Assert.notNull(advice, "Advice must not be null"); Assert.notNull(advice, "Advice must not be null");
if (advice instanceof IntroductionInfo) { if (advice instanceof IntroductionInfo introductionInfo) {
// We don't need an IntroductionAdvisor for this kind of introduction: // We don't need an IntroductionAdvisor for this kind of introduction:
// It's fully self-describing. // It's fully self-describing.
addAdvisor(pos, new DefaultIntroductionAdvisor(advice, (IntroductionInfo) advice)); addAdvisor(pos, new DefaultIntroductionAdvisor(advice, introductionInfo));
} }
else if (advice instanceof DynamicIntroductionAdvice) { else if (advice instanceof DynamicIntroductionAdvice) {
// We need an IntroductionAdvisor for this kind of introduction. // We need an IntroductionAdvisor for this kind of introduction.
@ -506,8 +506,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
this.advisorChainFactory = other.advisorChainFactory; this.advisorChainFactory = other.advisorChainFactory;
this.interfaces = new ArrayList<>(other.interfaces); this.interfaces = new ArrayList<>(other.interfaces);
for (Advisor advisor : advisors) { for (Advisor advisor : advisors) {
if (advisor instanceof IntroductionAdvisor) { if (advisor instanceof IntroductionAdvisor introductionAdvisor) {
validateIntroductionAdvisor((IntroductionAdvisor) advisor); validateIntroductionAdvisor(introductionAdvisor);
} }
Assert.notNull(advisor, "Advisor must not be null"); Assert.notNull(advisor, "Advisor must not be null");
this.advisors.add(advisor); this.advisors.add(advisor);
@ -580,8 +580,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MethodCacheKey && return (this == other || (other instanceof MethodCacheKey methodCacheKey &&
this.method == ((MethodCacheKey) other).method)); this.method == methodCacheKey.method));
} }
@Override @Override

View File

@ -188,8 +188,8 @@ class CglibAopProxy implements AopProxy, Serializable {
Enhancer enhancer = createEnhancer(); Enhancer enhancer = createEnhancer();
if (classLoader != null) { if (classLoader != null) {
enhancer.setClassLoader(classLoader); enhancer.setClassLoader(classLoader);
if (classLoader instanceof SmartClassLoader && if (classLoader instanceof SmartClassLoader smartClassLoader &&
((SmartClassLoader) classLoader).isClassReloadable(proxySuperClass)) { smartClassLoader.isClassReloadable(proxySuperClass)) {
enhancer.setUseCache(false); enhancer.setUseCache(false);
} }
} }
@ -365,8 +365,8 @@ class CglibAopProxy implements AopProxy, Serializable {
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof CglibAopProxy && return (this == other || (other instanceof CglibAopProxy cglibAopProxy &&
AopProxyUtils.equalsInProxy(this.advised, ((CglibAopProxy) other).advised))); AopProxyUtils.equalsInProxy(this.advised, cglibAopProxy.advised)));
} }
@Override @Override
@ -590,12 +590,12 @@ class CglibAopProxy implements AopProxy, Serializable {
if (proxy == other) { if (proxy == other) {
return true; return true;
} }
if (other instanceof Factory) { if (other instanceof Factory factory) {
Callback callback = ((Factory) other).getCallback(INVOKE_EQUALS); Callback callback = factory.getCallback(INVOKE_EQUALS);
if (!(callback instanceof EqualsInterceptor)) { if (!(callback instanceof EqualsInterceptor equalsInterceptor)) {
return false; return false;
} }
AdvisedSupport otherAdvised = ((EqualsInterceptor) callback).advised; AdvisedSupport otherAdvised = equalsInterceptor.advised;
return AopProxyUtils.equalsInProxy(this.advised, otherAdvised); return AopProxyUtils.equalsInProxy(this.advised, otherAdvised);
} }
else { else {
@ -719,8 +719,8 @@ class CglibAopProxy implements AopProxy, Serializable {
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object other) {
return (this == other || return (this == other ||
(other instanceof DynamicAdvisedInterceptor && (other instanceof DynamicAdvisedInterceptor dynamicAdvisedInterceptor &&
this.advised.equals(((DynamicAdvisedInterceptor) other).advised))); this.advised.equals(dynamicAdvisedInterceptor.advised)));
} }
/** /**
@ -962,9 +962,9 @@ class CglibAopProxy implements AopProxy, Serializable {
private static boolean equalsPointcuts(Advisor a, Advisor b) { private static boolean equalsPointcuts(Advisor a, Advisor b) {
// If only one of the advisor (but not both) is PointcutAdvisor, then it is a mismatch. // If only one of the advisor (but not both) is PointcutAdvisor, then it is a mismatch.
// Takes care of the situations where an IntroductionAdvisor is used (see SPR-3959). // Takes care of the situations where an IntroductionAdvisor is used (see SPR-3959).
return (!(a instanceof PointcutAdvisor) || return (!(a instanceof PointcutAdvisor pointcutAdvisor1) ||
(b instanceof PointcutAdvisor && (b instanceof PointcutAdvisor pointcutAdvisor2 &&
ObjectUtils.nullSafeEquals(((PointcutAdvisor) a).getPointcut(), ((PointcutAdvisor) b).getPointcut()))); ObjectUtils.nullSafeEquals(pointcutAdvisor1.getPointcut(), pointcutAdvisor2.getPointcut())));
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.

View File

@ -262,15 +262,15 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
} }
JdkDynamicAopProxy otherProxy; JdkDynamicAopProxy otherProxy;
if (other instanceof JdkDynamicAopProxy) { if (other instanceof JdkDynamicAopProxy jdkDynamicAopProxy) {
otherProxy = (JdkDynamicAopProxy) other; otherProxy = jdkDynamicAopProxy;
} }
else if (Proxy.isProxyClass(other.getClass())) { else if (Proxy.isProxyClass(other.getClass())) {
InvocationHandler ih = Proxy.getInvocationHandler(other); InvocationHandler ih = Proxy.getInvocationHandler(other);
if (!(ih instanceof JdkDynamicAopProxy)) { if (!(ih instanceof JdkDynamicAopProxy jdkDynamicAopProxy)) {
return false; return false;
} }
otherProxy = (JdkDynamicAopProxy) ih; otherProxy = jdkDynamicAopProxy;
} }
else { else {
// Not a valid comparison... // Not a valid comparison...

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2022 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.
@ -55,8 +55,8 @@ public class AdvisorAdapterRegistrationManager implements BeanPostProcessor {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AdvisorAdapter){ if (bean instanceof AdvisorAdapter advisorAdapter) {
this.advisorAdapterRegistry.registerAdvisorAdapter((AdvisorAdapter) bean); this.advisorAdapterRegistry.registerAdvisorAdapter(advisorAdapter);
} }
return bean; return bean;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@ -55,8 +55,8 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
@Override @Override
public Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException { public Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException {
if (adviceObject instanceof Advisor) { if (adviceObject instanceof Advisor advisor) {
return (Advisor) adviceObject; return advisor;
} }
if (!(adviceObject instanceof Advice advice)) { if (!(adviceObject instanceof Advice advice)) {
throw new UnknownAdviceTypeException(adviceObject); throw new UnknownAdviceTypeException(adviceObject);
@ -78,8 +78,8 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException { public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException {
List<MethodInterceptor> interceptors = new ArrayList<>(3); List<MethodInterceptor> interceptors = new ArrayList<>(3);
Advice advice = advisor.getAdvice(); Advice advice = advisor.getAdvice();
if (advice instanceof MethodInterceptor) { if (advice instanceof MethodInterceptor methodInterceptor) {
interceptors.add((MethodInterceptor) advice); interceptors.add(methodInterceptor);
} }
for (AdvisorAdapter adapter : this.adapters) { for (AdvisorAdapter adapter : this.adapters) {
if (adapter.supportsAdvice(advice)) { if (adapter.supportsAdvice(advice)) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@ -58,11 +58,11 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
super.setBeanFactory(beanFactory); super.setBeanFactory(beanFactory);
if (!(beanFactory instanceof ConfigurableListableBeanFactory)) { if (!(beanFactory instanceof ConfigurableListableBeanFactory clbf)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: " + beanFactory); "AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: " + beanFactory);
} }
initBeanFactory((ConfigurableListableBeanFactory) beanFactory); initBeanFactory(clbf);
} }
protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory) { protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory) {

View File

@ -473,8 +473,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
private Object buildProxy(Class<?> beanClass, @Nullable String beanName, private Object buildProxy(Class<?> beanClass, @Nullable String beanName,
@Nullable Object[] specificInterceptors, TargetSource targetSource, boolean classOnly) { @Nullable Object[] specificInterceptors, TargetSource targetSource, boolean classOnly) {
if (this.beanFactory instanceof ConfigurableListableBeanFactory) { if (this.beanFactory instanceof ConfigurableListableBeanFactory clbf) {
AutoProxyUtils.exposeTargetClass((ConfigurableListableBeanFactory) this.beanFactory, beanName, beanClass); AutoProxyUtils.exposeTargetClass(clbf, beanName, beanClass);
} }
ProxyFactory proxyFactory = new ProxyFactory(); ProxyFactory proxyFactory = new ProxyFactory();
@ -511,8 +511,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
// Use original ClassLoader if bean class not locally loaded in overriding class loader // Use original ClassLoader if bean class not locally loaded in overriding class loader
ClassLoader classLoader = getProxyClassLoader(); ClassLoader classLoader = getProxyClassLoader();
if (classLoader instanceof SmartClassLoader && classLoader != beanClass.getClassLoader()) { if (classLoader instanceof SmartClassLoader smartClassLoader && classLoader != beanClass.getClassLoader()) {
classLoader = ((SmartClassLoader) classLoader).getOriginalClassLoader(); classLoader = smartClassLoader.getOriginalClassLoader();
} }
return (classOnly ? proxyFactory.getProxyClass(classLoader) : proxyFactory.getProxy(classLoader)); return (classOnly ? proxyFactory.getProxyClass(classLoader) : proxyFactory.getProxy(classLoader));
} }
@ -527,8 +527,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
* @see AutoProxyUtils#shouldProxyTargetClass * @see AutoProxyUtils#shouldProxyTargetClass
*/ */
protected boolean shouldProxyTargetClass(Class<?> beanClass, @Nullable String beanName) { protected boolean shouldProxyTargetClass(Class<?> beanClass, @Nullable String beanName) {
return (this.beanFactory instanceof ConfigurableListableBeanFactory && return (this.beanFactory instanceof ConfigurableListableBeanFactory clbf &&
AutoProxyUtils.shouldProxyTargetClass((ConfigurableListableBeanFactory) this.beanFactory, beanName)); AutoProxyUtils.shouldProxyTargetClass(clbf, beanName));
} }
/** /**
@ -592,7 +592,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
*/ */
private Advisor[] resolveInterceptorNames() { private Advisor[] resolveInterceptorNames() {
BeanFactory bf = this.beanFactory; BeanFactory bf = this.beanFactory;
ConfigurableBeanFactory cbf = (bf instanceof ConfigurableBeanFactory ? (ConfigurableBeanFactory) bf : null); ConfigurableBeanFactory cbf = (bf instanceof ConfigurableBeanFactory _cbf ? _cbf : null);
List<Advisor> advisors = new ArrayList<>(); List<Advisor> advisors = new ArrayList<>();
for (String beanName : this.interceptorNames) { for (String beanName : this.interceptorNames) {
if (cbf == null || !cbf.isCurrentlyInCreation(beanName)) { if (cbf == null || !cbf.isCurrentlyInCreation(beanName)) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2022 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.
@ -46,8 +46,7 @@ public abstract class AbstractBeanFactoryAwareAdvisingPostProcessor extends Abst
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = (beanFactory instanceof ConfigurableListableBeanFactory ? this.beanFactory = (beanFactory instanceof ConfigurableListableBeanFactory clbf ? clbf : null);
(ConfigurableListableBeanFactory) beanFactory : null);
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@ -67,11 +67,11 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
@Override @Override
public final void setBeanFactory(BeanFactory beanFactory) { public final void setBeanFactory(BeanFactory beanFactory) {
if (!(beanFactory instanceof ConfigurableBeanFactory)) { if (!(beanFactory instanceof ConfigurableBeanFactory clbf)) {
throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory " + throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory " +
"that doesn't implement ConfigurableBeanFactory: " + beanFactory.getClass()); "that doesn't implement ConfigurableBeanFactory: " + beanFactory.getClass());
} }
this.beanFactory = (ConfigurableBeanFactory) beanFactory; this.beanFactory = clbf;
} }
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@ -66,9 +66,8 @@ public class LazyInitTargetSourceCreator extends AbstractBeanFactoryBasedTargetS
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource( protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
Class<?> beanClass, String beanName) { Class<?> beanClass, String beanName) {
if (getBeanFactory() instanceof ConfigurableListableBeanFactory) { if (getBeanFactory() instanceof ConfigurableListableBeanFactory clbf) {
BeanDefinition definition = BeanDefinition definition = clbf.getBeanDefinition(beanName);
((ConfigurableListableBeanFactory) getBeanFactory()).getBeanDefinition(beanName);
if (definition.isLazyInit()) { if (definition.isLazyInit()) {
return new LazyInitTargetSource(); return new LazyInitTargetSource();
} }

View File

@ -182,8 +182,8 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
if (targetExecutor == null) { if (targetExecutor == null) {
return null; return null;
} }
executor = (targetExecutor instanceof AsyncTaskExecutor ? executor = (targetExecutor instanceof AsyncTaskExecutor asyncTaskExecutor ?
(AsyncTaskExecutor) targetExecutor : new TaskExecutorAdapter(targetExecutor)); asyncTaskExecutor : new TaskExecutorAdapter(targetExecutor));
this.executors.put(method, executor); this.executors.put(method, executor);
} }
return executor; return executor;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@ -113,8 +113,8 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
Callable<Object> task = () -> { Callable<Object> task = () -> {
try { try {
Object result = invocation.proceed(); Object result = invocation.proceed();
if (result instanceof Future) { if (result instanceof Future<?> future) {
return ((Future<?>) result).get(); return future.get();
} }
} }
catch (ExecutionException ex) { catch (ExecutionException ex) {

View File

@ -75,7 +75,7 @@ class ScopedProxyBeanRegistrationAotProcessor implements BeanRegistrationAotProc
@Nullable @Nullable
private String getTargetBeanName(BeanDefinition beanDefinition) { private String getTargetBeanName(BeanDefinition beanDefinition) {
Object value = beanDefinition.getPropertyValues().get("targetBeanName"); Object value = beanDefinition.getPropertyValues().get("targetBeanName");
return (value instanceof String ? (String) value : null); return (value instanceof String targetBeanName ? targetBeanName : null);
} }
@Nullable @Nullable

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@ -82,8 +82,8 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
} }
private void resetAdviceMonitor() { private void resetAdviceMonitor() {
if (this.beanFactory instanceof ConfigurableBeanFactory) { if (this.beanFactory instanceof ConfigurableBeanFactory cbf) {
this.adviceMonitor = ((ConfigurableBeanFactory) this.beanFactory).getSingletonMutex(); this.adviceMonitor = cbf.getSingletonMutex();
} }
else { else {
this.adviceMonitor = new Object(); this.adviceMonitor = new Object();

View File

@ -107,8 +107,8 @@ public abstract class AopUtils {
public static Class<?> getTargetClass(Object candidate) { public static Class<?> getTargetClass(Object candidate) {
Assert.notNull(candidate, "Candidate object must not be null"); Assert.notNull(candidate, "Candidate object must not be null");
Class<?> result = null; Class<?> result = null;
if (candidate instanceof TargetClassAware) { if (candidate instanceof TargetClassAware targetClassAware) {
result = ((TargetClassAware) candidate).getTargetClass(); result = targetClassAware.getTargetClass();
} }
if (result == null) { if (result == null) {
result = (isCglibProxy(candidate) ? candidate.getClass().getSuperclass() : candidate.getClass()); result = (isCglibProxy(candidate) ? candidate.getClass().getSuperclass() : candidate.getClass());
@ -234,8 +234,8 @@ public abstract class AopUtils {
} }
IntroductionAwareMethodMatcher introductionAwareMethodMatcher = null; IntroductionAwareMethodMatcher introductionAwareMethodMatcher = null;
if (methodMatcher instanceof IntroductionAwareMethodMatcher) { if (methodMatcher instanceof IntroductionAwareMethodMatcher iamm) {
introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher; introductionAwareMethodMatcher = iamm;
} }
Set<Class<?>> classes = new LinkedHashSet<>(); Set<Class<?>> classes = new LinkedHashSet<>();
@ -281,8 +281,8 @@ public abstract class AopUtils {
* @return whether the pointcut can apply on any method * @return whether the pointcut can apply on any method
*/ */
public static boolean canApply(Advisor advisor, Class<?> targetClass, boolean hasIntroductions) { public static boolean canApply(Advisor advisor, Class<?> targetClass, boolean hasIntroductions) {
if (advisor instanceof IntroductionAdvisor) { if (advisor instanceof IntroductionAdvisor ia) {
return ((IntroductionAdvisor) advisor).getClassFilter().matches(targetClass); return ia.getClassFilter().matches(targetClass);
} }
else if (advisor instanceof PointcutAdvisor pca) { else if (advisor instanceof PointcutAdvisor pca) {
return canApply(pca.getPointcut(), targetClass, hasIntroductions); return canApply(pca.getPointcut(), targetClass, hasIntroductions);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 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.
@ -109,9 +109,9 @@ public abstract class ClassFilters {
} }
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || (other instanceof UnionClassFilter && return (this == obj || (obj instanceof UnionClassFilter that &&
ObjectUtils.nullSafeEquals(this.filters, ((UnionClassFilter) other).filters))); ObjectUtils.nullSafeEquals(this.filters, that.filters)));
} }
@Override @Override
@ -150,9 +150,9 @@ public abstract class ClassFilters {
} }
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || (other instanceof IntersectionClassFilter && return (this == obj || (obj instanceof IntersectionClassFilter that &&
ObjectUtils.nullSafeEquals(this.filters, ((IntersectionClassFilter) other).filters))); ObjectUtils.nullSafeEquals(this.filters, that.filters)));
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@ -56,7 +56,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
* @see #addInterface * @see #addInterface
*/ */
public DefaultIntroductionAdvisor(Advice advice) { public DefaultIntroductionAdvisor(Advice advice) {
this(advice, (advice instanceof IntroductionInfo ? (IntroductionInfo) advice : null)); this(advice, (advice instanceof IntroductionInfo introductionInfo ? introductionInfo : null));
} }
/** /**
@ -112,8 +112,8 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
@Override @Override
public void validateInterfaces() throws IllegalArgumentException { public void validateInterfaces() throws IllegalArgumentException {
for (Class<?> ifc : this.interfaces) { for (Class<?> ifc : this.interfaces) {
if (this.advice instanceof DynamicIntroductionAdvice && if (this.advice instanceof DynamicIntroductionAdvice dynamicIntroductionAdvice &&
!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) { !dynamicIntroductionAdvice.implementsInterface(ifc)) {
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " + throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
"does not implement interface [" + ifc.getName() + "] specified for introduction"); "does not implement interface [" + ifc.getName() + "] specified for introduction");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 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.
@ -98,8 +98,8 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
// Massage return value if possible: if the delegate returned itself, // Massage return value if possible: if the delegate returned itself,
// we really want to return the proxy. // we really want to return the proxy.
if (retVal == delegate && mi instanceof ProxyMethodInvocation) { if (retVal == delegate && mi instanceof ProxyMethodInvocation pmi) {
retVal = ((ProxyMethodInvocation) mi).getProxy(); retVal = pmi.getProxy();
} }
return retVal; return retVal;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 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.
@ -112,8 +112,8 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
// Massage return value if possible: if the delegate returned itself, // Massage return value if possible: if the delegate returned itself,
// we really want to return the proxy. // we really want to return the proxy.
if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) { if (retVal == this.delegate && mi instanceof ProxyMethodInvocation pmi) {
Object proxy = ((ProxyMethodInvocation) mi).getProxy(); Object proxy = pmi.getProxy();
if (mi.getMethod().getReturnType().isInstance(proxy)) { if (mi.getMethod().getReturnType().isInstance(proxy)) {
retVal = proxy; retVal = proxy;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 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.
@ -100,9 +100,9 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || (other instanceof NameMatchMethodPointcut && return (this == obj || (obj instanceof NameMatchMethodPointcut that &&
this.mappedNames.equals(((NameMatchMethodPointcut) other).mappedNames))); this.mappedNames.equals(that.mappedNames)));
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 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.
@ -45,9 +45,9 @@ public class RootClassFilter implements ClassFilter, Serializable {
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object obj) {
return (this == other || (other instanceof RootClassFilter && return (this == obj || (obj instanceof RootClassFilter that &&
this.clazz.equals(((RootClassFilter) other).clazz))); this.clazz.equals(that.clazz)));
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2022 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.
@ -77,12 +77,12 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'"); logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
} }
if (getBeanFactory() instanceof ConfigurableBeanFactory) { if (getBeanFactory() instanceof ConfigurableBeanFactory cbf) {
((ConfigurableBeanFactory) getBeanFactory()).destroyBean(getTargetBeanName(), target); cbf.destroyBean(getTargetBeanName(), target);
} }
else if (target instanceof DisposableBean) { else if (target instanceof DisposableBean disposableBean) {
try { try {
((DisposableBean) target).destroy(); disposableBean.destroy();
} }
catch (Throwable ex) { catch (Throwable ex) {
logger.warn("Destroy method on bean with name '" + getTargetBeanName() + "' threw an exception", ex); logger.warn("Destroy method on bean with name '" + getTargetBeanName() + "' threw an exception", ex);

View File

@ -100,9 +100,9 @@ public class HotSwappableTargetSource implements TargetSource, Serializable {
* objects are equal. * objects are equal.
*/ */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object obj) {
return (this == other || (other instanceof HotSwappableTargetSource && return (this == obj || (obj instanceof HotSwappableTargetSource that &&
this.target.equals(((HotSwappableTargetSource) other).target))); this.target.equals(that.target)));
} }
@Override @Override