Skip to content

Commit 9a0bfd7

Browse files
committed
Do not attempt nested PropertyHandler resolution for argument conversion
This is not actually triggered on 6.2.x but nevertheless worth aligning. Includes fix for return type declaration in PropertyAccessor subclasses. Includes related polishing from main commits. See gh-36024
1 parent 91a0c28 commit 9a0bfd7

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ private void processLocalProperty(PropertyTokenHolder tokens, PropertyValue pv)
489489
@Override
490490
@Nullable
491491
public Class<?> getPropertyType(String propertyName) throws BeansException {
492+
if (this.wrappedObject == null) {
493+
return null;
494+
}
492495
try {
493496
PropertyHandler ph = getPropertyHandler(propertyName);
494497
if (ph != null) {

spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public Object convertForProperty(@Nullable Object value, String propertyName) th
192192

193193
@Override
194194
@Nullable
195-
protected BeanPropertyHandler getLocalPropertyHandler(String propertyName) {
195+
protected PropertyHandler getLocalPropertyHandler(String propertyName) {
196196
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(propertyName);
197197
return (pd != null ? new BeanPropertyHandler((GenericTypeAwarePropertyDescriptor) pd) : null);
198198
}

spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected DirectFieldAccessor(Object object, String nestedPath, DirectFieldAcces
7373

7474
@Override
7575
@Nullable
76-
protected FieldPropertyHandler getLocalPropertyHandler(String propertyName) {
76+
protected PropertyHandler getLocalPropertyHandler(String propertyName) {
7777
FieldPropertyHandler propertyHandler = this.fieldMap.get(propertyName);
7878
if (propertyHandler == null) {
7979
Field field = ReflectionUtils.findField(getWrappedClass(), propertyName);

spring-context/src/main/java/org/springframework/cache/interceptor/CacheEvaluationContextFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ class CacheEvaluationContextFactory {
3939
@Nullable
4040
private Supplier<ParameterNameDiscoverer> parameterNameDiscoverer;
4141

42+
4243
CacheEvaluationContextFactory(StandardEvaluationContext originalContext) {
4344
this.originalContext = originalContext;
4445
}
4546

47+
4648
public void setParameterNameDiscoverer(Supplier<ParameterNameDiscoverer> parameterNameDiscoverer) {
4749
this.parameterNameDiscoverer = parameterNameDiscoverer;
4850
}
@@ -54,6 +56,7 @@ public ParameterNameDiscoverer getParameterNameDiscoverer() {
5456
return this.parameterNameDiscoverer.get();
5557
}
5658

59+
5760
/**
5861
* Creates a {@link CacheEvaluationContext} for the specified operation.
5962
* @param rootObject the {@code root} object to use for the context

spring-core/src/test/java/org/springframework/core/MethodParameterTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ void nestedWithTypeIndexReturnsNewInstance() throws Exception {
237237
assertThat(m3.getTypeIndexForCurrentLevel()).isEqualTo(3);
238238
}
239239

240-
public int method(String p1, long p2) {
240+
241+
public int method(String str, long lng) {
241242
return 42;
242243
}
243244

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,15 @@ public void register(T mapping, Object handler, Method method) {
636636
HandlerMethod handlerMethod = createHandlerMethod(handler, method);
637637
validateMethodMapping(handlerMethod, mapping);
638638

639-
Set<String> directPaths = AbstractHandlerMethodMapping.this.getDirectPaths(mapping);
639+
Set<String> directPaths = getDirectPaths(mapping);
640640
for (String path : directPaths) {
641641
this.pathLookup.add(path, mapping);
642642
}
643643

644644
String name = null;
645-
if (getNamingStrategy() != null) {
646-
name = getNamingStrategy().getName(handlerMethod, mapping);
645+
HandlerMethodMappingNamingStrategy<T> namingStrategy = getNamingStrategy();
646+
if (namingStrategy != null) {
647+
name = namingStrategy.getName(handlerMethod, mapping);
647648
addMappingName(name, handlerMethod);
648649
}
649650

0 commit comments

Comments
 (0)