Skip to content

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

Closed

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;
    }

Activity

  1. changed the title [-]DubboBeanDefinitionParser#parse method add property to beanDefinition issue[/-] [+]DubboBeanDefinitionParser#parse method add property to beanDefinition may cause a NotWritablePropertyException[/+] on Nov 17, 2018
  2. added 2 commits that reference this issue on Nov 17, 2018
  3. added a commit that references this issue on Nov 20, 2018
    5ea6b33
  4. added 6 commits that reference this issue on Dec 6, 2018
    05e815d
    5c8827f
    19e2886
    648794e
    890e57d
    9ec86f8
  5. added a commit that references this issue on Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions