Merge branch '6.2.x'
This commit is contained in:
@@ -668,7 +668,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
return (this == other || (other instanceof MethodCacheKey that && this.method == that.method));
|
||||
return (this == other || (other instanceof MethodCacheKey that &&
|
||||
(this.method == that.method || this.method.equals(that.method))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,15 +43,18 @@ class DefaultAdvisorAutoProxyCreatorTests {
|
||||
* @see StaticMethodMatcherPointcut#matches(Method, Class)
|
||||
*/
|
||||
@Test // gh-33915
|
||||
void staticMethodMatcherPointcutMatchesMethodIsInvokedAgainForActualMethodInvocation() {
|
||||
void staticMethodMatcherPointcutMatchesMethodIsNotInvokedAgainForActualMethodInvocation() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
DemoBean.class, DemoPointcutAdvisor.class, DefaultAdvisorAutoProxyCreator.class);
|
||||
DemoPointcutAdvisor demoPointcutAdvisor = context.getBean(DemoPointcutAdvisor.class);
|
||||
DemoBean demoBean = context.getBean(DemoBean.class);
|
||||
|
||||
assertThat(demoPointcutAdvisor.matchesInvocationCount).as("matches() invocations before").isEqualTo(2);
|
||||
// Invoke multiple times to ensure additional invocations don't affect the outcome.
|
||||
assertThat(demoBean.sayHello()).isEqualTo("Advised: Hello!");
|
||||
assertThat(demoPointcutAdvisor.matchesInvocationCount).as("matches() invocations after").isEqualTo(3);
|
||||
assertThat(demoBean.sayHello()).isEqualTo("Advised: Hello!");
|
||||
assertThat(demoBean.sayHello()).isEqualTo("Advised: Hello!");
|
||||
assertThat(demoPointcutAdvisor.matchesInvocationCount).as("matches() invocations after").isEqualTo(2);
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -139,10 +139,10 @@ class BeanFactoryTransactionTests {
|
||||
// Invokes: getAge() * 2 and setAge() * 1 --> 2 + 1 = 3 method invocations.
|
||||
assertGetsAreNotTransactional(testBean);
|
||||
|
||||
// The transaction pointcut is currently asked if it matches() for all method
|
||||
// invocations, but we cannot assert it's equal to 3 since the pointcut may be
|
||||
// optimized and only invoked once.
|
||||
assertThat(txnPointcut.counter).as("txnPointcut").isGreaterThanOrEqualTo(1).isLessThanOrEqualTo(3);
|
||||
// The matches(Method, Class) method of the static transaction pointcut should not
|
||||
// have been invoked for the actual invocation of the getAge() and setAge() methods.
|
||||
assertThat(txnPointcut.counter).as("txnPointcut").isZero();
|
||||
|
||||
assertThat(preInterceptor.counter).as("preInterceptor").isEqualTo(3);
|
||||
assertThat(postInterceptor.counter).as("postInterceptor").isEqualTo(3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user