From 37458d28d92b169fdb58dbec2353bd05b8a0c6c1 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 5 Mar 2023 13:33:04 +0100 Subject: [PATCH] Covert InterceptorAndDynamicMethodMatcher to a record --- .../InterceptorAndDynamicMethodMatcher.java | 21 +++++++------------ .../framework/ReflectiveMethodInvocation.java | 4 ++-- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/InterceptorAndDynamicMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/framework/InterceptorAndDynamicMethodMatcher.java index 79f5101f09..41366d7fee 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/InterceptorAndDynamicMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/InterceptorAndDynamicMethodMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,20 +21,13 @@ import org.aopalliance.intercept.MethodInterceptor; import org.springframework.aop.MethodMatcher; /** - * Internal framework class, combining a MethodInterceptor instance - * with a MethodMatcher for use as an element in the advisor chain. + * Internal framework record, combining a {@link MethodInterceptor} instance + * with a {@link MethodMatcher} for use as an element in the advisor chain. * * @author Rod Johnson + * @author Sam Brannen + * @param interceptor the {@code MethodInterceptor} + * @param matcher the {@code MethodMatcher} */ -class InterceptorAndDynamicMethodMatcher { - - final MethodInterceptor interceptor; - - final MethodMatcher methodMatcher; - - public InterceptorAndDynamicMethodMatcher(MethodInterceptor interceptor, MethodMatcher methodMatcher) { - this.interceptor = interceptor; - this.methodMatcher = methodMatcher; - } - +record InterceptorAndDynamicMethodMatcher(MethodInterceptor interceptor, MethodMatcher matcher) { } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java index 6b57eb9fa4..3640d0c3dd 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java @@ -169,8 +169,8 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea // Evaluate dynamic method matcher here: static part will already have // been evaluated and found to match. Class targetClass = (this.targetClass != null ? this.targetClass : this.method.getDeclaringClass()); - if (dm.methodMatcher.matches(this.method, targetClass, this.arguments)) { - return dm.interceptor.invoke(this); + if (dm.matcher().matches(this.method, targetClass, this.arguments)) { + return dm.interceptor().invoke(this); } else { // Dynamic matching failed.