Skip to content

Spring cannot find setter if subclass overrides getter narrowing return type [SPR-10995] #15623

Closed
@spring-projects-issues

Description

@spring-projects-issues

Piotr Findeisen opened SPR-10995 and commented

Steps to Reproduce

  1. Create a class with a property (getter/setter) of type Bar.
  2. Create a subclass that overrides the getter narrowing the return type to MoreBar extends Bar.
  3. Try to set the property in XML config.

Expectation

It worked in 3.1.2, so it should work now.

Failing Exception

org.springframework.beans.factory.BeanCreationException: Error creating bean ...
...
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'bar' of bean class [...]: Bean property 'bar' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Affects: 3.1.4

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions