Skip to content

DubboBeanDefinitionParser#parse method add property to beanDefinition may cause a NotWritablePropertyException #2798

@kexianjun

Description

@kexianjun

I found that when dubbo sets a properties for a beanDefinition when parsing an XML in DubboBeanDefinitionParser#parse method, the propertyName is split with "-",which is the propertyName used in xml file,not the bean class attrubute name,if somewhere has configed such a property,the beanDefinition contains a property with a name like xxx-yy,and the bean class attribute name like xxxYy,when spring populateBean and set this property's value,it will throw a NotWritablePropertyException because the property’s name is unmatched.The code is shown below.

private static BeanDefinition parse(Element element, ParserContext parserContext, Class<?> beanClass, boolean required) {
...
        for (Method setter : beanClass.getMethods()) {
           ...
                String property = StringUtils.camelToSplitName(name.substring(3, 4).toLowerCase() + name.substring(4), "-");
                props.add(property);
                Method getter = null;
               ...
                                beanDefinition.getPropertyValues().addPropertyValue(property, reference);
...
     
        return beanDefinition;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions