Skip to content

Commit 08237da

Browse files
committed
Simplify equals() implementation in PerTargetInstantiationModelPointcut
For equivalence, we only need to compare the preInstantiationPointcut fields since they include the declaredPointcut fields. In addition, we should not compare the aspectInstanceFactory fields since LazySingletonAspectInstanceFactoryDecorator does not implement equals(). See gh-31238
1 parent f7496a3 commit 08237da

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,12 @@ private boolean isAspectMaterialized() {
302302

303303
@Override
304304
public boolean equals(@Nullable Object other) {
305+
// For equivalence, we only need to compare the preInstantiationPointcut fields since
306+
// they include the declaredPointcut fields. In addition, we should not compare the
307+
// aspectInstanceFactory fields since LazySingletonAspectInstanceFactoryDecorator does
308+
// not implement equals().
305309
return (this == other || (other instanceof PerTargetInstantiationModelPointcut that &&
306-
ObjectUtils.nullSafeEquals(this.declaredPointcut, that.declaredPointcut) &&
307-
ObjectUtils.nullSafeEquals(this.preInstantiationPointcut, that.preInstantiationPointcut) &&
308-
ObjectUtils.nullSafeEquals(this.aspectInstanceFactory, that.aspectInstanceFactory)));
310+
ObjectUtils.nullSafeEquals(this.preInstantiationPointcut, that.preInstantiationPointcut)));
309311
}
310312

311313
@Override

0 commit comments

Comments
 (0)