Fix property lookup for projections on Kotlin types.
This commit makes sure to use the target objects method to determine the property used for the projection. Closes: #3127 Original pull request: #3129
This commit is contained in:
committed by
Mark Paluch
parent
3b481609e6
commit
ac09de8c72
@@ -33,6 +33,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Johannes Englmeier
|
||||
* @author Christoph Strobl
|
||||
* @since 1.10
|
||||
*/
|
||||
class PropertyAccessingMethodInterceptor implements MethodInterceptor {
|
||||
@@ -54,12 +55,11 @@ class PropertyAccessingMethodInterceptor implements MethodInterceptor {
|
||||
@Override
|
||||
public Object invoke(@SuppressWarnings("null") MethodInvocation invocation) throws Throwable {
|
||||
|
||||
Method method = invocation.getMethod();
|
||||
|
||||
if (ReflectionUtils.isObjectMethod(method)) {
|
||||
if (ReflectionUtils.isObjectMethod(invocation.getMethod())) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
Method method = lookupTargetMethod(invocation, target.getWrappedClass());
|
||||
PropertyDescriptor descriptor = BeanUtils.findPropertyForMethod(method);
|
||||
|
||||
if (descriptor == null) {
|
||||
@@ -81,4 +81,12 @@ class PropertyAccessingMethodInterceptor implements MethodInterceptor {
|
||||
private static boolean isSetterMethod(Method method, PropertyDescriptor descriptor) {
|
||||
return method.equals(descriptor.getWriteMethod());
|
||||
}
|
||||
|
||||
private static Method lookupTargetMethod(MethodInvocation invocation, Class<?> targetType) {
|
||||
|
||||
Method method = BeanUtils.findMethod(targetType, invocation.getMethod().getName(),
|
||||
invocation.getMethod().getParameterTypes());
|
||||
|
||||
return method != null ? method : invocation.getMethod();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user