From 081d81e5b09ba3d1497aa38223ec0acf64f2194c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 20 Jan 2010 15:31:20 +0000 Subject: [PATCH] fixed getPropertyTypeDescriptor to work for nested indexed property as well as for array property (SPR-6710) --- .../main/java/org/springframework/beans/BeanWrapperImpl.java | 3 ++- .../org/springframework/beans/PropertyAccessorUtils.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index fda4003b7d..14c6dfef77 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -355,7 +355,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException { try { - PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName); + String actualPropertyName = PropertyAccessorUtils.getPropertyName(propertyName); + PropertyDescriptor pd = getPropertyDescriptorInternal(actualPropertyName); if (pd != null) { Class type = getPropertyType(propertyName); if (pd.getReadMethod() != null) { diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java b/org.springframework.beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java index a433ec959d..53d1377282 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 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. @@ -32,7 +32,8 @@ public abstract class PropertyAccessorUtils { * @return the actual property name, without any key elements */ public static String getPropertyName(String propertyPath) { - int separatorIndex = propertyPath.indexOf(PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR); + int separatorIndex = (propertyPath.endsWith(PropertyAccessor.PROPERTY_KEY_SUFFIX) ? + propertyPath.indexOf(PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR) : -1); return (separatorIndex != -1 ? propertyPath.substring(0, separatorIndex) : propertyPath); }