Skip to content

Commit

Permalink
Simplify equals() implementation in PerTargetInstantiationModelPointcut
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbrannen committed Sep 23, 2023
1 parent f7496a3 commit 08237da
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,12 @@ private boolean isAspectMaterialized() {

@Override
public boolean equals(@Nullable Object other) {
// 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().
return (this == other || (other instanceof PerTargetInstantiationModelPointcut that &&
ObjectUtils.nullSafeEquals(this.declaredPointcut, that.declaredPointcut) &&
ObjectUtils.nullSafeEquals(this.preInstantiationPointcut, that.preInstantiationPointcut) &&
ObjectUtils.nullSafeEquals(this.aspectInstanceFactory, that.aspectInstanceFactory)));
ObjectUtils.nullSafeEquals(this.preInstantiationPointcut, that.preInstantiationPointcut)));
}

@Override
Expand Down

0 comments on commit 08237da

Please sign in to comment.