Issue Details (XML | Word | Printable)

Key: SPR-191
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Marc Portier
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Framework

BeanWrapperImpl marks readable properties as 'unradable' (inside array's and java.util.Properties)

Created: 28/Jun/04 08:14 AM   Updated: 07/Jul/04 04:05 AM
Component/s: SpringCORE
Affects Version/s: None
Fix Version/s: 1.1 RC1

Time Tracking:
Not Specified

Environment:
tests performed with version 1.0.2 and cvs-head
(ie revision 1.47 of BeanWrapperImpl.java in place)


 Description  « Hide
I've just made a simple bean with

setStringArray(String[] arr);
setProperties(Properties props);

in combination with

<bean...>
  <property name="stringArray">
    <value>one,two,three,four</value>
  </property>
  <property name="properties">
    <value>
    # inline properties file:
    test.one = yes
    test.two = no
    </value>
  </property>
</bean>


then I wrapped the configured bean in a BeanWrapperImpl and found the
following to be counter-intuitive:


1/
wrapper.getPropertyValue("stringArray[2]") returns "three" (no surprise)
BUT: wrapper.isReadable("stringArrray[2]") returns false?


2/
wrapper.getPropertyValue("properties[test.two]") returns "no" (no surprise)
BUT: wrapper.isReadable("properties[test.two]") returns false?


briefly browsing the cvs the reason for the mismatch between the two methods seems to come from how they lookup their propertyDescriptor.


line 993:
PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName);



versus lines 531-538:
public Object getPropertyValue(String propertyName) throws ...{
    BeanWrapperImpl nestedBw = ...
    String[] tokens = getPropertyNameTokens(getFinalPath(nestedBw, propertyName));
    return nestedBw.getPropertyValue(tokens[0], tokens[1], tokens[2]);
}

protected Object getPropertyValue(String propertyName, String actualName, String key) throws BeansException {

    PropertyDescriptor pd = getPropertyDescriptorInternal(actualName);
    ...

notice how actualName is used here and not propertyName!



it's probably fair to suspect an equal mismatch between isWritableProperty(...) and setPropertyValue(...)?


 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Juergen Hoeller added a comment - 07/Jul/04 04:05 AM
Fixed through special fallback checks in isReadableProperty and isWritableProperty.